/** * 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!"; } }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { if ($this->checkProjectPermissions($id) == false) { return ['error' => 'Access Forbiden']; } return $this->repository->find($id); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { try { return $this->repository->find($id); } catch (ModelNotFoundException $e) { return ['error' => true, 'message' => 'Project not Found']; } }
public function isMember($project_id, $member_id) { $project = $this->repository->find($project_id)->members()->find(['member_id' => $member_id]); if (count($project)) { return true; } return false; }
public function delete($id) { try { $this->repository->find($id)->delete(); } catch (\Exception $e) { return ['error' => true, 'message' => $e->getMessage()]; } }
public function find($id) { try { return $this->repository->find($id); } catch (ModelNotFoundException $e) { return ['error' => true, 'message' => 'Projeto não encontrado']; } }
public function show($id) { try { $rtrn = $this->repository->find($id); return $rtrn; } catch (ModelNotFoundException $e) { return ['error' => true, 'message' => 'Projeto não existe']; } }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { //if($this->checkProjectPermissions($id) == false){ if ($this->service->checkProjectPermissions($id) == false) { return ['error' => 'Access Forbidden']; } //return $this->repository->findWhere(['project_id' => $id, 'id' => $noteId]); return $this->repository->find($id); //return $this->repository->with(['client', 'user'])->find($id); }
public function destroy($id) { try { $project = $this->repository->find($id); $project->delete(); $msg['status'] = "Y"; $msg['message'] = "Successfully deleted record"; return $msg; } catch (ValidatorException $ex) { return ['error' => true, 'message' => $ex->getMessageBag()]; } }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { /*$userId = \Authorizer::getResourceOwnerId(); if($this->repository->isOwner($id, $userId) == false){ return ['success'=>false]; }*/ if ($this->checkProjectPermissions($id) == false) { return ['error' => 'Access Forbidden']; } return $this->repository->find($id); //return Client::find($id); }
public function destroy($id) { try { if ($this->repository->find($id)->destroy()) { return ['error' => false, 'message' => 'Projeto deletado.']; } } catch (ModelNotFoundException $e) { return ['error' => true, 'message' => 'Projeto não encontrado.']; } catch (\PDOException $e) { return ['success' => false, 'message' => 'Existem projetos cadastrados a este cliente!']; } }
public function update(array $data, $id) { try { $this->validator->with($data)->passesOrFail(); $P = $this->repository->find($id)->update($data); if ($P) { // return "O projeto '".$data['name']."', foi editado com sucesso!"; return ['error' => false, 'message' => "O projeto '" . $data['name'] . "', foi editado com sucesso!"]; } } catch (ValidatorException $e) { return ['error' => true, 'message' => $e->getMessageBag()]; } }
public function create(array $data) { try { $this->validator->with($data)->passesOrFail(); $user_id = \Authorizer::getResourceOwnerId(); if ($data['owner_id'] != $user_id) { return Errors::basic('Voce nao pode inserir um novo projeto cujo dono nao seja voce.'); } $project = Project::create($data); $resp = $this->projectMemberService->create(['project_id' => $project->id, 'user_id' => $data['owner_id']]); return $this->repository->find($project->id); } catch (ValidatorException $e) { return Errors::basic($e->getMessageBag()); } }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { if ($this->isNotOwner($id) and $this->isNotMember($id)) { return ['error' => 'Access forbirdden']; } $this->repository->find($id)->delete($id); }
public function create($projectId, $file, array $data) { try { $this->validator->with($data)->passesOrFail(); $data['extension'] = $file->getClientOriginalExtension(); $data['file'] = md5(date('Y-m-d H:i:s')) . "." . $data['extension']; $this->storage->put($data['file'], $this->filesystem->get($file)); $project = $this->projectRepository->find($projectId); $file = $project->files()->create($data); return $this->find($projectId, $file->id); } catch (ValidatorException $e) { return ['error' => true, 'message' => $e->getMessageBag()]; } catch (\Exception $e) { return ['error' => true, 'message' => $e->getMessage()]; } }
public function showTasks($id) { try { return response()->json($this->repository->find($id)->tasks->all()); } catch (ModelNotFoundException $ex) { return $this->notFound($id); } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { if ($this->service->checkProjectPermissions($id) == false) { return ['error' => 'Access Forbidden']; } $this->repository->find($id)->delete(); //$this->repository->delete($id); }
/** * @param $projectId * @param $userId * @return array */ public function isMember($projectId, $userId) { try { return $this->repository->find($projectId)->members()->find($userId) ? true : false; } catch (\Exception $e) { return ["error" => true, "message" => $e->getMessage()]; } }
public function members($project_id) { if (is_null(Project::find($project_id))) { return Errors::invalidId($project_id); } // Foi feita uma adaptacao abaixo por causa do uso de presenters return $this->repository->find($project_id)['data']['membros']; }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $project = $this->repository->find($id); if ($project) { $files = $this->repository->skipPresenter()->find($id)->files; foreach ($files as $file) { $this->fileService->delete($id, $file->id); } if ($this->repository->delete($id)) { return ['success' => true]; } else { return ['success' => false]; } } else { return ['success' => false, 'msg' => "Project not found!"]; } }
public function isMember(array $data) { try { return $this->repository->find($data['project_id'])->members->where('member_id', $data['member_id']); } catch (ModelNotFoundException $e) { return ['error' => true, 'message' => 'Invalid member or project']; } }
public function removeMember($id, $id_user) { try { $this->repository->find($id)->members()->detach($id_user); return ['message' => 'User delete project success']; } catch (\PDOException $e) { return ['error' => true, 'message' => $e->getMessage()]; } catch (ModelNotFoundException $e) { return ['error' => true, 'message' => $e->getMessage()]; } }
public function isMember($id, $memberId) { try { $member = $this->repository->find($id)->members()->find($memberId); if (!$member) { return response()->json(['error' => true, 'message' => ['isMember' => "Member ID {$memberId} is not a member in this project"]]); } return response()->json(['error' => false, 'message' => ['isMember' => "{$member->name} is a member in this project"]]); } catch (ModelNotFoundException $ex) { return ['error' => true, 'message' => 'ID not found']; } }
/** * 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; $rtrn = $this->repository->checkOwnershipAndMembership($user_id, $project_id); #dd($user_id, $project_id, $rtrn); if ($rtrn) { return $next($request); } //return ['error'=>'Access denied']; abort(403, 'Você não tem permissão para acessar este projeto'); #inutilizado abaixo $project_id = $request->project; /*if( $this->repository->isMember($project_id,$user_id) == false){ return ['error'=>'Access forbidden']; }*/ if (count($this->repository->find($user_id)->projects()->where(['project_id' => $project_id])->get()) == false) { return ['error' => 'Access forbidden']; } return $next($request); }
public function members($id) { try { $members = $this->repository->find($id)->members()->get(); if (count($members)) { return $members; } return $this->erroMsgm('Esse projeto ainda não tem membros.'); } catch (ModelNotFoundException $e) { return $this->erroMsgm('Projeto não encontrado.'); } catch (QueryException $e) { return $this->erroMsgm('Cliente não encontrado.'); } catch (\Exception $e) { return $this->erroMsgm('Ocorreu um erro ao exibir os membros do projeto.'); } }
public function removeMember($id, $memberId) { try { $project = $this->repository->find($id); if ($this->isMember($id, $memberId)) { $project->members()->detach($memberId); } else { return ['error' => true, 'message' => 'This user don\'t take part in this project.']; } return ['success' => true]; } catch (ModelNotFoundException $e) { return ['error' => true, 'message' => 'No data found.']; } catch (\Exception $e) { return ['error' => true, 'message' => 'An error occurred when trying find the data. Try again later.']; } }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { return $this->repository->find($id)->delete(); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $this->repository->find($id)->delete(); //$this->service->delete($id); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { return $this->repository->find($id); //return Client::find($id); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { return $this->repository->find($id); }