Closed bilginnet closed 4 months ago
It seems to me that you made some mistake in the configuration. Upload a demo repo with the code showing the problem https://spatie.be/laravel-permission/creating-a-demo-app
The "there is no role with ID x" error is thrown by Role::findById()
, which is called from getStoredRole()
, which is called by collectRoles()
, which is called by assignRole()
.
Your posted assignRole()
call looks strange. Why are you passing a nested array?
When reformatting your posted code of:
$userOrgManager->assignRole([$roleOrgManager->id => ['organization_id' => $organization->id]]);
it looks like this:
$userOrgManager->assignRole([
$roleOrgManager->id => [
'organization_id' => $organization->id
]
]);
That's not the kind of array that assignRole()
accepts. assignRole()
accepts a one-dimensional array of role id
s or role objects
/records or role name
s.
uuid
(or org_uuid
) ... that's part of the schema, not a valid record id
. (If you were giving a role name
of uuid
, then perhaps "uuid" might be acceptable, but if it gave an error related to such a name
, then it would say that it couldn't find a role with that name
, not "ID".)
Thus, as parallels999 mentioned, something is wrong in your code or your configuration.
We need to see your complete code related to this. As mentioned, please create a fresh repository for a basic app which recreates this exact problem. Dear contributor,
because this issue seems to be inactive for quite some time now, I've automatically closed it. If you feel this issue deserves some attention from my human colleagues feel free to reopen it.
Versions
PHP version: 8.1 Database version: mysql latest
changed migration file:
Enum class:
and Seeder file:
and i got this error - There is no role with ID
org_uuid
for guardapi
already checked .. this role created on the roles table with guard api .
i tried to create roles without organization id but i got same error again.
why i need to fill team_id (it set required and primary in migration file) on the roles table when set teams => true in the permissions.php (config)