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(); $project = $this->repository->create($data); return self::getProject($project->id); } catch (ValidatorException $ex) { return ['error' => true, 'message' => $ex->getMessageBag()]; } }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { try { return $this->repository->create($request->all()); } catch (ValidatorException $e) { $error = $e->getMessageBag(); return ['error' => true, 'message' => "Erro ao cadastrar o projeto, alguns campos são obrigatórios!", 'messages' => $error->getMessages()]; } catch (\Exception $e) { return $this->erroMsgm('Ocorreu um erro ao cadastrar o projeto.'); } }
public function create(array $data) { try { $this->validator->with($data)->passesOrFail(); return $this->repository->create($data); } catch (ValidatorException $e) { return response()->json(['error' => true, 'message' => $e->getMessageBag()]); } //enviar email //dispara notificacao }
public function update(array $data) { try { $this->validator->with($data)->passesOrFail(); return $this->repository->create($data); } catch (ValidatorException $e) { return ['error' => true, 'message' => $e->getMessageBag()]; } catch (ModelNotFoundException $e) { return ['error' => true, 'message' => 'Não foi possível atualizar as informações do projeto. Projeto não encontrado.']; } }
public function create(array $data) { try { $this->validator->with($data)->passesOrFail(); $p = $this->repository->create($data); if ($p) { return "Projeto criado com sucesso!"; } } catch (ValidatorException $e) { return ['error' => true, 'message' => $e->getMessageBag()]; } }
public function create(array $data) { // enviar um email // disparar notificacao // postar um tweet try { $this->validator->with($data)->passesOrFail(); return $this->repository->create($data); } catch (ValidatorException $e) { return ['error' => true, 'message' => $e->getMessageBag()]; } }
/** * @param array $data * @return mixed */ public function create(array $data) { try { $data['owner_id'] = \Authorizer::getResourceOwnerId(); $this->validator->with($data)->passesOrFail(); return $this->repository->create($data); } catch (ValidatorException $e) { return ['error' => true, 'message' => $e->getMessageBag()]; } catch (\Exception $e) { return ["error" => true, "message" => $e->getMessage()]; } }
/** * @param array $data * @return \Illuminate\Http\JsonResponse */ public function create(array $data) { try { $this->validator->with($data)->passesOrFail(ValidatorInterface::RULE_CREATE); $create = $this->repository->create($data); $msg = "Projeto criado com sucesso."; Log::info($msg); return response()->json(["message" => $msg, "data" => $create->toArray()], 200); } 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 create(array $data) { // diversos serviços // enviar email // disparar notificacao try { //dd($data); $this->validator->with($data)->passesOrFail(); $result = $this->repository->create($data); //dd($result); // adiciona somente um membro ao projeto if (!empty($result->id) && !empty($data['user_id'])) { $this->addMember(['project_id' => $result->id, 'user_id' => $data['user_id']]); } return $result; } catch (ValidatorException $e) { return ['error' => true, 'message' => $e->getMessageBag()]; } }
/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(Request $request) { return $this->repository->create($request->all()); }