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 Illuminate\Validation\Factory::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('Illuminate\Validation\Factory');
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!
Validator::make(). Make sure the first parameter is the input array eg:$request->all()and the second parameter is your rules array eg:['email' => 'required|email'...]