I followed laravel documentation about Form Request Validation. and im not sure if get it correctly. i created a make:request EmployeeRequest to validate an employee form. but for some reasons it only redirects me to a blank page with "forbidden" as message
// this is my request code
public function rules()
{
return [
'email' => 'bail|required|email|unique:employees|max:255',
'first_name' => 'bail|required|max:50|min:2',
'last_name' => 'bail|required|max:50|min:2',
'date_of_birth' => 'bail|required',
'contact_number' => 'bail|required|max:11',
'image' => 'bail|required|image',
];
}
//then i called it in my controller like this
public function store(EmployeeRequest $request)
{
//my code if everything is valid
}
(when entering invalid data) it only redirects me to a blank page with an echo of forbidden. im not sure if i understand it correctly. but im expecting that it will automatically redirects to the previous page with errors
Maybe you have to authorize the user, or change the
authorize()function toreturn true. From the docs: