Closed Jeordy closed 1 month ago
Sorry, it seems that the model is skipped when using seeders.
Sorry, it seems that the model is skipped when using seeders.
If you specify ('use
') the intended model in your seeder, it will use it.
Sorry, it seems that the model is skipped when using seeders.
If you specify ('
use
') the intended model in your seeder, it will use it.
Thank you, the seeder was using the spatie model directly, not our own.
Description
I want to switch to UUIDs and have followed the steps for implementing them. I also created the Role and Permission models accordingly. But, when using the HasUuids trait, I get an error:
SQLSTATE[HY000]: General error: 1364 Field 'id' doesn't have a default value (Connection: mysql, SQL: insert into
permissions(
guard_name,
name,
description,
updated_at,
created_at) values (web, users.view, {"en":"View Users","nl":"Toon Gebruikers"}, 2024-09-26 12:35:57, 2024-09-26 12:35:57))
So, the trait is not triggered.Then I added a custom boot function to the model, like so:
protected static function boot() { parent::boot(); static::creating(function ($model) { if (empty($model->{$model->getKeyName()})) { $model->{$model->getKeyName()} = Str::uuid()->toString(); } }); }
But it's not going through this model, even a dump in the boot function does not appear...
In permission config I added:
`'models' => [ /*
Spatie\Permission\Contracts\Permission
contract. */ 'permission' => App\Models\Permission::class,App\Models\Role
contract. */ 'role' => App\Models\Role::class, ],`The correct custom models are configured.
Does anyone have the same issue?
Steps To Reproduce
Follow the documentation on changing to UUID's.
Example Application
No response
Version of spatie/laravel-permission package:
6.9.0
Version of laravel/framework package:
11.16.0
PHP version:
8.3.11
Database engine and version:
Mysql 8.0.36
OS: Windows/Mac/Linux version:
Mac/Windows