public function addMember($projectId, $memberId) { if (!$this->repository->addMember($projectId, $memberId)) { return ['success' => false, 'message' => 'O usuário informado já é membro do projeto.']; } return ['success' => true]; }
/** * @param array $data * * @return array */ public function addMember(array $data) { try { $this->memberValidator->with($data)->passesOrFail(); return $this->repository->addMember($data['project_id'], $data['member_id']); } catch (ValidatorException $e) { return ['error' => true, 'message' => $e->getMessageBag()]; } }
public function addMember($data) { try { $this->validator->with($data)->passesOrFail(); $result = $this->projectRepository->addMember($data['project_id'], $data['user_id']); return ['success' => $result, "message" => 'Adicionar membro ao projeto.']; } catch (ValidatorException $e) { return ['error' => true, 'message' => $e->getMessageBag(), "messageDev" => 'ValidatorException']; } catch (\Exception $e) { return ["error" => true, "message" => 'Falha ao adicionar membro ao projeto.', "messageDev" => $e->getMessage()]; } }
/** * Add a new member on a project * @param int $projectId * @param int $memberId * @return mix */ public function addMember($data) { $this->validator->with($data)->passesOrFail(); return $this->repository->addMember($data['project_id'], $data['user_id']); }