Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems using UUID There is no [permission] with ID 85d49adb-e164-41e5-afd2-3e3c45af660a for guard web. #2737

Open
josecastro22 opened this issue Oct 15, 2024 · 2 comments

Comments

@josecastro22
Copy link

josecastro22 commented Oct 15, 2024

Description

Im using this seeder to create an admin user and assing all roles in database

        $user = User::create([
            'email' => '[email protected]',
            'password' => 'password',
        ]);

        $perfil = Perfil::create([
            'user_id' => $user->id,
            'name' => 'Admin',
            'last_name' => 'App',
        ]);

        $role = Role::create(['name' => 'admin']);

        $permissions = Permission::pluck('uuid', 'uuid')->all();

        $role->syncPermissions($permissions);

        $user->assignRole([$role->uuid]);

The problem its when execute $role->syncPermissions($permissions); i get this error

There is no [permission] with ID 488a71c3-d01b-45fc-8fee-03422322c4ec for guard web.

I follow the error and come to

vendor\spatie\laravel-permission\src\Traits\HasPermissions.php:491

So i encountered with this line

return $this->getPermissionClass()::findById($permissions, $this->getDefaultGuardName());

So i try to get the Permission just using

Permission::findById('488a71c3-d01b-45fc-8fee-03422322c4ec', 'web')

And there is not problem. So what its wrong?

Steps To Reproduce

...

Example Application

No response

Version of spatie/laravel-permission package:

^6.9

Version of laravel/framework package:

^11.9

PHP version:

^8.2

Database engine and version:

No response

OS: Windows/Mac/Linux version:

No response

@parallels999
Copy link
Contributor

Seems like cache problem again, there are many similar threads

@drbyte
Copy link
Collaborator

drbyte commented Oct 16, 2024

Yes, could be a cache issue, or perhaps something incomplete with the UUID configuration that's causing -> getKeyName() to not return the correct field name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants