public function addMember(array $data) { //dd($data); $result = $this->repositoryMember->create($data); //dd($result); return $result; }
public function create(array $data) { try { $this->validator->with($data)->passesOrFail(); return $this->repository->create($data); } catch (ValidatorException $e) { return ['error' => true, 'message' => $e->getMessageBag()]; } }
public function create(array $data) { try { $this->validator->with($data)->passesOrFail(); return $this->repository->create($data); } catch (ValidatorException $e) { return Errors::basic($e->getMessageBag()); } }
public function create(array $data) { try { $this->validator->with($data)->passesOrFail(); return $this->repository->create($data); } catch (ValidatorException $e) { return ['error' => true, 'message' => $e->getMessageBag()]; } catch (QueryException $e) { return ['error' => true, 'message' => 'Não foi possível criar o membro. Projeto não existe!']; } }
public function create(array $data) { try { $this->validator->with($data)->passesOrFail(); $aux = $this->repository->skipPresenter()->findWhere(['user_id' => $data['user_id'], 'project_id' => $data['project_id']]); if (count($aux) > 0) { return Errors::basic("Falha. Este usuario ja eh membro deste projeto"); } return $this->repository->create($data); } catch (ValidatorException $e) { return Errors::basic($e->getMessageBag()); } }
/** * @param array $data * @return \Illuminate\Http\JsonResponse */ public function add(array $data) { try { $this->validator->with($data)->passesOrFail(ValidatorInterface::RULE_CREATE); $create = $this->repository->create($data); $msg = "Membro adicionado com sucesso."; Log::info($msg); return response()->json(["message" => $msg, "data" => $create->toArray()]); } catch (ValidatorException $e) { return response()->json([$e->getMessageBag()], 400); } //QueryException tratado em Exceptions/Handler.php }
public function create(array $data) { // enviar email // disparar notificacao // postar tweet try { $this->validator->with($data)->passesOrFail(); $project = $this->repository->create($data); //Adiciona o owner como membro $this->project_member_repository->create(['project_id' => $project['data']['id'], 'user_id' => $project['data']['owner_id']]); return $project; } catch (ValidatorException $e) { return ['error' => true, 'message' => $e->getMessageBag()]; } }
public function addMember(array $data) { try { $this->validatorProjectMember->with($data)->passesOrFail(); return $this->repositoryProjectMember->create($data); } catch (ValidatorException $e) { return ['error' => true, 'message' => $e->getMessageBag()]; } catch (ModelNotFoundException $e) { return ['error' => true, 'message' => $e->getMessage()]; } }
public function store(Request $request, $id) { $data = $request->all(); $data['project_id'] = $id; return $this->repository->create($data); }
/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(Request $request) { $request['project_id'] = $request['id']; return $this->repository->create($request->all()); }