'Call to a member function contains() on null ( spatie laravel

I'm facing this error on add can permission in view:

Error Call to a member function contains() on null (

When I debug found here in AuthServiceProvider.php:

/**
 * Fetch the collection of site permissions.
 *
 * @return \Illuminate\Database\Eloquent\Collection
 */
protected function getPermissions()
{
    return Permission::with('roles')->get();
}


Solution 1:[1]

Sometimes there are policies in place, some directory called policies could be in the project.

look in the database did you add the permission? because the permission looks like it can't be found.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Marcel Santing