请求表单重定向到禁止页面

Request Form Redirecting to Forbidden page

我遵循了 laravel 有关表单请求验证的文档。 我不确定是否正确理解。我创建了一个 make:request EmployeeRequest 来验证员工表单。但由于某些原因,它只会将我重定向到一个空白页面,其中 "forbidden" 作为消息

// 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
}

(输入无效数据时) 它只会将我重定向到一个带有禁止回声的空白页面。 我不确定我是否理解正确。但我希望它会自动重定向到错误的前一页

也许你必须授权用户,或者将 authorize() 功能更改为 return true 。来自 docs:

If the authorize method returns false, a HTTP response with a 403 status code will automatically be returned and your controller method will not execute.

If you plan to have authorization logic in another part of your application, return true from the authorize method:

    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }