/**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     if ($this->service->checkProjectPermission($id) == false) {
         return ['error' => 'Acesso negado ao projeto!'];
     }
     $this->repository->skipPresenter()->find($id)->delete();
 }
 /**
  * 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' => 'Acesso negado ao projeto!'];
     }
     return $next($request);
 }
 public function update(array $data, $id)
 {
     try {
         $this->validator->with($data)->passesOrFail();
         return $this->repository->update($data, $id);
     } catch (ValidationException $e) {
         return ['error' => true, 'message' => $e->getMessageBag()];
     }
 }
 public function checkProjectMember($projectId)
 {
     $userId = \Authorizer::getResourceOwnerId();
     return $this->repository->hasMember($projectId, $userId);
 }
 public function checkProjectMember($projectFileId)
 {
     $userId = \Authorizer::getResourceOwnerId();
     $projectId = $this->repository->skipPresenter()->find($projectFileId)->project_id;
     return $this->projectRepository->hasMember($projectId, $userId);
 }