App\Policies\DocumentPolicy::view PHP Method

view() public static method

public static view ( User $user, Document $document ) : boolean
$user app\models\User
$document Document
return boolean
    public static function view(User $user, $document)
    {
        if ($user->hasPermission('view_all')) {
            return true;
        }
        if ($document->expense) {
            if ($document->expense->invoice) {
                return $user->can('view', $document->expense->invoice);
            }
            return $user->can('view', $document->expense);
        }
        if ($document->invoice) {
            return $user->can('view', $document->invoice);
        }
        return $user->owns($item);
    }
DocumentPolicy