douwei7976 2017-09-09 07:22
浏览 181
已采纳

自定义Laravel FormRequest自动调整方法验证

Laravel allow us to authorize, or not, a FormRequest to be processed via the authorize method. If the request isn't authorized, it will through a \Illuminate\Auth\Access\AuthorizationException exception, with a message:

This action is unauthorized.

Is there somehow to customize this message?

See that I want to customize the message itself. Customizing the error messages of attributes I know it is possible!

  • 写回答

2条回答 默认 最新

  • doushi1957 2017-09-10 00:29
    关注

    To change the message you can add the following to your FormRequest class.

    protected function failedAuthorization()
    {
        throw new AuthorizationException('Your new message goes here.');
    }
    

    Hope this helps!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部