Php 覆盖laravel forbiddenResponse()方法
所以,当一个页面被触发时,我想返回我自己的403页面 处理它的方法似乎在Php 覆盖laravel forbiddenResponse()方法,php,validation,laravel-5.2,http-status-code-403,Php,Validation,Laravel 5.2,Http Status Code 403,所以,当一个页面被触发时,我想返回我自己的403页面 处理它的方法似乎在vendor/laravel/framework/source/illumb/Foundation/Http/FormRequest.php中 我如何覆盖禁止响应()方法 /** * Get the response for a forbidden operation. * * @return \Illuminate\Http\Response */ public fun
vendor/laravel/framework/source/illumb/Foundation/Http/FormRequest.php
中
我如何覆盖禁止响应()
方法
/**
* Get the response for a forbidden operation.
*
* @return \Illuminate\Http\Response
*/
public function forbiddenResponse()
{
return new Response('Forbidden', 403);
}
我在laracasts社区读过。但是没有人提到他们到底是如何覆盖它的。如果这意味着我的更改在更新中丢失,我不想修补框架源代码。我该怎么做呢
我建议的替换方法很简单,我将使用abort(403)
和我自己的视图/errors/403.blade.php
,这似乎很好
public function forbiddenResponse()
{
abort(403);
}
用户bestmomo建议覆盖failedAuthorization()
更符合逻辑。因此,牢记这一切,我应该如何着手进行这一改变