Laravel 8 throw_if() {#collection-method}
2021-07-19 10:40 更新
在给定的布尔表达式结果为 true
时,throw_if
函数抛出给定的异常:
throw_if(! Auth::user()->isAdmin(), AuthorizationException::class);
throw_if(
! Auth::user()->isAdmin(),
AuthorizationException::class,
'You are not allowed to access this page'
);
以上内容是否对您有帮助:
更多建议: