Open lokken opened 1 year ago
TIL didn't know you could cast Enum as AsEnumArrayObject
or AsEnumCollection
, that syntax might be a little tricky 😕
'statuses' => AsEnumCollection::class.':'.ServerStatus::class,
When you run php artisan model:show User
what does that output for that database_roles
look like?
It's Gollum's tricksy tricks.
database_roles fillable..string(255) / Illuminate\Database\Eloquent\Casts\AsEnumCollection:App\Enums\DatabaseRole
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
For instance, in User model
Here is the error when running the model:typer tool.
Class "Illuminate\Database\Eloquent\Casts\AsEnumCollection:App\Enums\DatabaseRole" does not exist
It's a simple workaround to remove the AsEnumCollection temporarily, generate the types, and then add [] to the end of the generated type, but thought you may want to support this use case. Thanks, have a good one.