public function create($project_id, array $data)
 {
     try {
         $data['project_id'] = $project_id;
         #dd($data);
         $this->validator->with($data)->passesOrFail();
         return $this->repository->create($data);
     } catch (ValidatorException $e) {
         return ['error' => true, 'message' => $e->getMessageBag()];
     }
 }
Example #2
0
 public function removeMember($project_id, $member_id)
 {
     $project = Project::find($project_id);
     if (is_null($project)) {
         return Errors::invalidId($project_id);
     }
     if (is_null(User::find($member_id))) {
         return Errors::invalidId($member_id);
     }
     if ($member_id == $project->owner_id) {
         return Errors::basic("Não é possível remover o dono do projeto.");
     }
     $pm = $this->repository->findMemberAssociation($project_id, $member_id);
     if (is_null($pm)) {
         return Errors::basic("Este usuário não é membro do projeto.");
     }
     return $this->projectMemberService->delete($pm->id);
 }
 public function delete($id)
 {
     $entity = Project::find($id);
     if (is_null($entity)) {
         return Errors::invalidId($id);
     }
     foreach ($entity->tasks as $task) {
         $this->projectTaskService->delete($task->id);
     }
     foreach ($entity->notes as $note) {
         $this->projectNoteService->delete($note->id);
     }
     foreach ($entity->memberAssociations as $pm) {
         $this->projectMemberService->delete($pm->id);
     }
     $this->repository->delete($id);
     return ['message' => "Registro deletado!"];
 }
 public function destroy($id, $idProjectMember)
 {
     $this->service->delete($idProjectMember);
 }
 /**
  * @param $projectId
  * @param $memberId
  * @return bool
  */
 public function isMember($projectId, $memberId)
 {
     return (bool) $this->service->isMember($projectId, $memberId);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     return $this->service->create($request->all());
 }
 public function update(Request $request, $id)
 {
     return $this->service->update($request->all(), $id);
 }
 public function isMember($id_project, $id_user)
 {
     return $this->service->isMember($id_project, $id_user);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param int $id
  * @param  int $memberId
  * @return Response
  */
 public function destroy($id, $memberId)
 {
     return $this->service->delete($id, $memberId);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @return Response
  */
 public function destroy($projectId, $id)
 {
     return $this->service->removeMember($projectId, $id);
 }
 /**
  * @param $id
  * @return mixed
  */
 public function destroy($id_project, $id_member)
 {
     return $this->service->destroy($id_member);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request, $id)
 {
     $data = $request->all();
     $data['project_id'] = $id;
     return $this->service->create($data);
 }
 public function destroy($project_id, $member_id)
 {
     return $this->service->delete($member_id);
 }