spatie/laravel-permission

Error: Call to a member function merge() on array in src\Traits\HasPermissions.php on line 348

abo-habeba opened this issue · 1 comments

When using
// All permissions which apply to the user (inherited and direct)
$user->getAllPermissions();
I get this error

Error: Call to a member function merge() on array in file C:\laragon\www\ecommerce\vendor\spatie\laravel-permission\src\Traits\HasPermissions.php on line 348
image

public function getAllPermissions(): Collection
{
/** @var Collection $permissions */
$permissions = $this->permissions;
if (method_exists($this, 'roles')) {
$permissions = $permissions->merge($this->getPermissionsViaRoles());
}
return $permissions->sort()->values();
}

It looks like your User model probably has a $permissions property that you've added to it, which is conflicting with this package.

See https://spatie.be/docs/laravel-permission/v6/prerequisites#content-must-not-have-a-permission-or-permissions-property-nor-a-permissions-method