if (Gate::allows('update-post', $post)) {
//
}
if (Gate::denies('update-post', $post)) {
abort(403);
}
当然,您还可以检查给定的User实例是否具有给定的能力:
if ($request->user()->can('update-post', $post)) {
// The user is allowed to update the post...
}
if ($request->user()->cannot('update-post', $post)) {
abort(403);
}