TypeError on resource where column is an Enum
I have a User Model, and did like this:
php artisan make:filament-resource UserResource -G
and when I try to view the users i get this: I get it even if I remove the column that uses enum the enum: What am I missing ?
and when I try to view the users i get this: I get it even if I remove the column that uses enum the enum: What am I missing ?
17 Replies
Do you have any casts defined on the User Model?
can you add the code of the enum class also here. If you use
HasLabel
on the enum, the text column should automatically use it. https://filamentphp.com/docs/3.x/support/enums#using-the-enum-label-with-a-text-column-in-your-tableLooks fine. OK, can you send me the
TextColumn
code on the resource that binds the user_level
Tables\Columns\TextColumn::make('user_level')
->numeric()
->sortable(),
not sure what the
EnumHelper
does, can you try removing that trait to see if that fixes.Solution
Why do you have
numeric
method on the TextColumn?can you remove that
-G
the make command made it like this
did you generate the code before casting the column to UserLevel Enum? If so, the make command would use the type of the column on the DB to set that method. Remove that since you have a cast on the modal and that should do it
no, code was created after - I'm trying to switch from Nova to Filament on this
I just did a php artisan make:filament-resource UserResource -G --force
and this is the outcome
Tables\Columns\TextColumn::make('user_level')
->numeric()
->sortable(),
so maybe a bug @Dan Harrin 🙂
please open an issue with reproduction
din't removing the
->numeric()
method no help?yes, that helped
but the 'bug' is that this is generated
by the command
ok
@Dan Harrin created a bug and a github repro to show the issue