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()];
     }
 }
Пример #2
0
 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()];
     }
 }