Laravel - Authorization - Authorizing Actions Via Gates

To authorize an action using gates, you should use the allows or denies methods provided by the Gate facade. Note that you are not required to pass the currently authenticated user to these methods. Laravel will automatically take care of passing the user into the gate closure. It is typical to call the gate authorization methods within your application's controllers before performing an action that requires authorization:

    
    

If you would like to determine if a user other than the currently authenticated user is authorized to perform an action, you may use the forUser method on the Gate facade:

    
    if (Gate::forUser($user)->allows('update-post', $post)) {
        // The user can update the post...
    }
    
    if (Gate::forUser($user)->denies('update-post', $post)) {
        // The user can't update the post...
    }
	

You may authorize multiple actions at a time using the any or none methods:

    
    if (Gate::any(['update-post', 'delete-post'], $post)) {
        // The user can update or delete the post...
    }
    
    if (Gate::none(['update-post', 'delete-post'], $post)) {
        // The user can't update or delete the post...
    }