本文整理汇总了PHP中CodeProject\Repositories\ProjectRepository类的典型用法代码示例。如果您正苦于以下问题:PHP ProjectRepository类的具体用法?PHP ProjectRepository怎么用?PHP ProjectRepository使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ProjectRepository类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
if (!$this->checkProjectPermissions($id)) {
return ['error' => 'Access forbidden'];
}
return $this->repository->find($id);
}
示例2: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
$p = $this->repository->find($id)->delete();
if ($p) {
return "O projeto {$id} foi deletado com sucesso!";
}
}
示例3: createFile
public function createFile(array $data)
{
$project = $this->repository->skipPresenter()->find($data['project_id']);
//dd($project);
$projectFile = $project->files()->create($data);
$this->storage->put($projectFile->id . "." . $data['extension'], $this->filesystem->get($data['file']));
}
示例4: createFile
public function createFile(array $data)
{
$project = $this->repository->skipPresenter()->find($data['project_id']);
$projectFile = $project->files()->create($data);
$arquivo = $projectFile->id . "." . $data['extension'];
\Storage::put($arquivo, \File::get($data['file']));
}
示例5: delete
public function delete($id)
{
try {
$this->repository->delete($id);
} catch (ModelNotFoundException $e) {
return response()->json(['error' => true, 'message' => "Project id {$id} not found"]);
}
}
示例6: destroy
public function destroy($id)
{
try {
return $this->repository->delete($id);
} catch (ModelNotFoundException $e) {
return ['error' => true, 'message' => 'Projeto não encontrado'];
}
}
示例7: update
public function update(array $data, $id)
{
try {
$this->validator->with($data)->passesOrFail();
return $this->repository->update($data, $id);
} catch (ValidatorException $e) {
return ['error' => true, 'message' => $e->getMessageBag()];
}
}
示例8: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$userId = Authorizer::getResourceOwnerId();
$projectId = $request->project;
if ($this->repository->isOwner($projectId, $userId) == false) {
return ['success' => false, 'userId' => 'Forbidden'];
}
return $next($request);
}
示例9: checkProjectPermissions
private function checkProjectPermissions($projectId)
{
$this->repository->skipPresenter(true);
if ($this->checkProjectOwner($projectId) or $this->checkProjectMember($projectId)) {
$this->repository->skipPresenter(false);
return true;
}
return false;
}
示例10: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$userId = Authorizer::getResourceOwnerId();
$projectId = $request->projects;
if (!$this->repository->isOwner($projectId, $userId)) {
return ['error' => 'Access forbidden'];
}
return $next($request);
}
示例11: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$userId = Authorizer::getResourceOwnerId();
$projectId = $request->project;
if ($this->repository->isOwner($projectId, $userId) == false) {
return ['error' => 'Access Denied!'];
}
return $next($request);
}
示例12: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$userId = \Authorizer::getResourceOwnerId();
$projectId = $request->projects;
if ($this->repository->isOwner($projectId, $userId) == false) {
return ['error' => 'Access denied! You must be the project owner to access this resource'];
}
return $next($request);
}
示例13: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$userId = \Authorizer::getResourceOwnerId();
$projectId = $request->id;
if ($this->repository->isOwner($projectId, $userId) == false) {
return ['error' => true, 'message' => 'Access forbidden'];
}
return $next($request);
}
示例14: removeMember
public function removeMember($projectId, $memberId)
{
try {
$result = $this->projectRepository->removeMember($projectId, $memberId);
return ['success' => $result, "message" => 'Remover membro do projeto.'];
} catch (\Exception $e) {
return ["error" => true, "message" => 'Falha ao remover membro do projeto.', "messageDev" => $e->getMessage()];
}
}
示例15: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$user_id = \Authorizer::getResourceOwnerId();
$project_id = $request->project;
$projects = $this->repository->skipPresenter()->findWhere(['id' => $project_id, 'owner_id' => $user_id]);
if (count($projects) == false) {
return ['error' => 'Access forbidden'];
}
return $next($request);
}