public function update(array $data, $id) { try { $this->validator->with($data)->passesOrFail(); return $this->repository->update($data, $id); } catch (ValidatorException $e) { return ['error' => true, 'message' => $e->getMessageBag()]; } }
public function create(array $data) { /* * Here we could insert business rules, like: * -> Send a e-mail * -> Post a tweet * -> Trigger a notification */ try { $this->validator->with($data)->passesOrFail(); return $this->repository->create($data); } catch (ValidatorException $e) { return ["error" => true, "message" => $e->getMessageBag()]; } }