public function update(array $data, $id) { try { $this->validator->with($data)->passesOrFail(ValidatorInterface::RULE_UPDATE); } catch (ValidatorException $e) { return ['error' => 'validation_fail', 'error_description' => $e->getMessageBag()->all()]; } $this->rep->update($data, $id); }
/** * * override parent method if own messages available * * @param null $action * @return bool */ public function passes($action = null) { if (!empty($this->messages)) { $rules = $this->getRules($action); $validator = $this->validator->make($this->data, $rules, $this->messages); if ($validator->fails()) { $this->errors = $validator->messages(); return false; } return true; } return parent::passes($action); }
public function getRules($action = null) { $action == ValidatorInterface::RULE_UPDATE ? $this->id = request()->route('users') : null; return parent::getRules($action); }