Ejemplo n.º 1
0
 public function find($id)
 {
     if (is_null(Project::find($id))) {
         return Errors::invalidId($id);
     }
     return $this->repository->with(['client', 'owner'])->find($id);
 }
Ejemplo n.º 2
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     if ($this->checkProjectPermissions($id) == false) {
         return "Access Forbidden";
     }
     return $this->repository->with('client')->with('user')->findOrFail($id);
 }
Ejemplo n.º 3
0
 /**
  * Display the specified resource.
  *
  * @param  int $id
  * @return Response
  */
 public function show($id)
 {
     //        if ($this->checkProjectOwner($id)==false){
     //            return ['error' => 'Access forbidden'];
     //        }
     return $this->repository->with(['owner', 'client'])->find($id);
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     if ($this->checkProjectPermissions($id) == false) {
         return ['msg' => 'Forbidden'];
     }
     return $this->repository->with(['owner', 'notes', 'client', 'members'])->find($id);
 }
Ejemplo n.º 5
0
 public function listMembers($id_project)
 {
     try {
         return $this->repository->with(['members'])->find($id_project);
     } catch (ModelNotFoundException $e) {
         return ['error' => true, 'message' => 'Projeto não existe'];
     }
 }
 public function getProject($id = "")
 {
     if ($id) {
         return $this->repository->with(['owner', 'client'])->find($id);
     } else {
         return $this->repository->with(['owner', 'client'])->all();
     }
 }
Ejemplo n.º 7
0
 public function show($id)
 {
     try {
         return ["success" => $this->repository->with(['owner', 'client'])->find($id)];
     } catch (ModelNotFoundException $e) {
         return ["success" => false, "message" => "Projeto ID: {$id} inexistente!"];
     }
 }
Ejemplo n.º 8
0
 public function show($id)
 {
     try {
         return $this->repository->with(['owner', 'client', 'notes', 'tasks', 'members'])->find($id);
     } catch (ModelNotFoundException $e) {
         return ['error' => true, 'message' => $e->getMessage()];
     }
 }
 public function read($id)
 {
     try {
         return response()->json($this->repository->with(['owner', 'client'])->find($id));
     } catch (ModelNotFoundException $ex) {
         return response()->json(['error' => true, 'message' => "Project id {$id} not found"]);
     }
 }
Ejemplo n.º 10
0
 public function find($id)
 {
     try {
         $this->setPresenter();
         return $this->repository->with(['owner', 'client'])->find($id);
     } catch (\Exception $e) {
         return ['error' => true, 'message' => $e->getMessage()];
     }
 }
 /**
  * Display the specified resource.
  *
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     try {
         return $this->repository->with(['owner', 'client'])->find($id);
     } catch (ModelNotFoundException $e) {
         return $this->erroMsgm('Projeto não encontrado.');
     } catch (\Exception $e) {
         return $this->erroMsgm('Ocorreu um erro ao exibir o projeto.');
     }
 }
Ejemplo n.º 12
0
 /**
  * @param $id
  * @return array|mixed
  */
 public function find($id)
 {
     try {
         return $this->repository->with(['client', 'owner', 'notes'])->find($id);
     } catch (\Exception $e) {
         if (get_class($e) == 'Illuminate\\Database\\Eloquent\\ModelNotFoundException') {
             return ['error' => true, 'message' => 'Project does not exist' + $message];
         }
     }
 }
Ejemplo n.º 13
0
 public function show($id)
 {
     try {
         // return $this->repository->find($id);
         // return $this->repository->with(['owner', 'client'])->find($id);
         return $this->repository->with(['owner', 'client'])->find($id);
     } catch (Exception $e) {
         return ['error' => true, 'message' => $e->getMessage()];
     }
 }
 public function removeMember($id, $memberId)
 {
     try {
         //$user->roles()->detach($roleId);
         //$this->repository->find($id)->members()->detach($memberId);
         $this->repository->with(['members'])->find($id)->detach($memberId);
         return response()->json(['error' => false, 'message' => ['removeMember' => "Member ID {$memberId} removed"]]);
     } catch (ModelNotFoundException $ex) {
         return ['error' => true, 'message' => 'ID not found'];
     }
 }
Ejemplo n.º 15
0
 public function destroy($id)
 {
     if (count(self::show($id)) == 0) {
         return ['error' => true, 'message' => 'Nao encontrado'];
     } else {
         if (count($this->repository->with(['project'])->findWhere(['id' => $id])) > 0) {
             return ['error' => true, 'message' => 'Este Cliente tem Projetos'];
         } else {
             return $this->repository->delete($id);
         }
     }
 }
Ejemplo n.º 16
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     try {
         if (!$this->service->checkProjectPermissions($id)) {
             return $this->erroMsgm("O usuário não tem acesso a esse projeto");
         }
         return $this->repository->with(['owner', 'client'])->find($id);
     } catch (ModelNotFoundException $e) {
         return $this->erroMsgm('Projeto não encontrado.');
     } catch (NoActiveAccessTokenException $e) {
         return $this->erroMsgm('Usuário não está logado.');
     } catch (\Exception $e) {
         return $this->erroMsgm('Ocorreu um erro ao exibir o projeto.');
     }
 }
 public function showMembers($id)
 {
     try {
         return response()->json($this->repository->with(['members'])->find($id));
     } catch (ModelNotFoundException $ex) {
         return $this->notFound($id);
     }
 }
Ejemplo n.º 18
0
 public function isMember($id, $memberId)
 {
     try {
         return $this->repository->with(['members'])->find($id)->members()->get()->find($memberId) !== null;
     } catch (\Exception $e) {
         return ['error' => true, 'message' => 'An error occurred when trying to delete the data. Try again later.'];
     }
 }
Ejemplo n.º 19
0
 /**
  * Display the specified resource.
  *
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     //return $this->repository->find($id);
     //return $this->repository->with(['owner', 'client'])->find($id);
     //return['userId' => Authorizer::getResourceOwnerId()];
     //        $userId = Authorizer::getResourceOwnerId();
     //
     //        if ($this->repository->isOwner($id, $userId) == false) {
     //            return ['success' => false];
     //        }
     try {
         //if ($this->checkProjectOwner($id) == false) {
         if ($this->checkProjectPermissions($id) == false) {
             return ['error' => 'Access forbidden'];
         }
         return $this->repository->with(['owner', 'client'])->find($id);
     } catch (ModelNotFoundException $e) {
         return ['error' => true, 'message' => 'Não foi possível exibir o projeto! Projeto não encontrado!'];
     }
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $this->repository->with('owner');
     $this->repository->with('client');
     return $this->repository->findWhere(['owner_id' => Authorizer::getResourceOwnerId()]);
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //return $this->repository->with(['owner','client'])->all();
     return $this->repository->with(['owner', 'client'])->findWhere(['owner_id' => \Authorizer::getResourceOwnerId()]);
     //return $this->repository->all();
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     return $this->repository->with('owner')->with('client')->scopeQuery(function ($q) {
         return $q->where('owner_id', Authorizer::getResourceOwnerId())->orWhereRaw('EXISTS (SELECT 1 FROM project_members WHERE project_members.user_id = ' . Authorizer::getResourceOwnerId() . ' AND project_members.project_id = projects.id)');
     })->all();
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     return $this->repository->with(['owner', 'client', 'notes', 'tasks', 'members'])->findWhere(['owner_id' => \Authorizer::getResourceOwnerId()]);
 }
Ejemplo n.º 24
0
 /**
  * get a Project
  *
  * @param  int  $id
  * @return Entities\Project
  */
 public function find($id)
 {
     return $this->repository->with(['owner', 'client'])->find($id);
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //return $this->repository->all();
     return $this->repository->with(['owner', 'client'])->all();
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     return $this->repository->with('members')->all();
 }