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

Update uuid.md #2438

Merged
merged 2 commits into from
Aug 19, 2023
Merged

Update uuid.md #2438

merged 2 commits into from
Aug 19, 2023

Conversation

ChillMouse
Copy link
Contributor

Resolve problems with Laravel 10. Ex version of uuid.md doesn`t correct working. In this manual -- all good

Resolve problems with Laravel 10. Ex version of uuid.md doesn`t correct working. In this manual -- all good
class Permission extends SpatiePermission
{
use HasFactory, HasUuids;
protected $primaryKey = 'id';
Copy link
Contributor

@erikn69 erikn69 May 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also primary key id field on Role/Permission can be changed, see #2096, #2092
Just use protected $primaryKey = 'uuid'; on models, and update migration file, it is tested

'(\'id\'); // permission id',
'(\'id\'); // role id',
'references(\'id\') // permission id',
'references(\'id\') // role id',

'(\'permission_test_id\');',
'(\'role_test_id\');',
'references(\'permission_test_id\')',
'references(\'role_test_id\')',


LEAVE THE FIELD NAME AS id unless you also change it in dozens of other places.

this comment is not updated,

OPTIONAL: If you also want the roles and permissions to use a UUID for their `id` value, then you'll need to also change the id fields accordingly, and manually set the primary key. LEAVE THE FIELD NAME AS `id` unless you also change it in dozens of other places.

Related #2089

@drbyte
Copy link
Collaborator

drbyte commented Aug 19, 2023

Thanks

@drbyte
Copy link
Collaborator

drbyte commented Aug 19, 2023

Note that I removed some of the properties in the example models because the HasUuids trait already handles them.

@drbyte drbyte merged commit 7920916 into spatie:main Aug 19, 2023
20 checks passed
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

Successfully merging this pull request may close these issues.

3 participants