Laravel Authorization Writing Policies


Example

Writing Policies follows much the same pattern as writing Gates. The content permission gate can be rewritten as a Policy like this:

function view($user, $content)
{
    return $user->isSubscribedTo($content->id);
}

Policies can contain more methods as needed to take care of all authorisation cases for a model.