Ejemplo n.º 1
0
 /**
  * Execute the command.
  *
  * @param array $incidents
  *
  * @return array
  */
 public function check($incidents)
 {
     if (empty($incidents)) {
         return $this->failed('Empty resultset cannot be validated');
     }
     foreach ($incidents as $incident) {
         if (!is_object($incident)) {
             return $this->failed('Parser did not gave the correct incident objects in an array');
         }
         $validator = Validator::make($incident->toArray(), Incident::createRules());
         if ($validator->fails()) {
             return $this->error(implode(' ', $validator->messages()->all()));
         }
     }
     return $this->success('');
 }
Ejemplo n.º 2
0
 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     switch ($this->method) {
         case 'GET':
             break;
         case 'DELETE':
             break;
         case 'POST':
             return Incident::createRules();
         case 'PUT':
             break;
         case 'PATCH':
             return response('Unauthorized.', 401);
         default:
             break;
     }
     return [];
 }
Ejemplo n.º 3
0
 /**
  * @param $model
  *
  * @return mixed
  */
 protected function getValidator($model)
 {
     return Validator::make($model->toArray(), Incident::createRules());
 }