I’m working with Laravel and every time I submit my form it gives me this error:
ErrorException in Factory.php line 91: Argument 2 passed to IlluminateValidationFactory::make() must be of the type array, null given, called in /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/FormRequest.php on line 83 and defined
This is some code for the controller, even when I don’t try to send data to the database it gives me this error. (now it’s just redirecting)
public function store(StoreProjectRequest $request) { return Redirect::to('/index'); }
This is how I defined my routes:
Route::get('/projects','ProjectsController@index'); Route::get('/create','ProjectsController@create'); Route::post('/create','ProjectsController@store');
The line the error refers to is what is in the return section here:
protected function getValidatorInstance() { $factory = $this->container->make('IlluminateValidationFactory'); if (method_exists($this, 'validator')) { return $this->container->call([$this, 'validator'], compact('factory')); } return $factory->make( $this->all(), $this->container->call([$this, 'rules']), $this->messages(), $this->attributes() ); }
Can anyone help me? Thank you!
Advertisement
Answer
Problem is in your StoreProjectRequest
and it’s rules()
method. It should return array and in your code it probably returns something else. Check it, please.