filamentphp / filament

A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS.
https://filamentphp.com
MIT License
15.93k stars 2.54k forks source link

php artisan make:fileament-resource generate wrong code if a column is an enum #12717

Closed rabol closed 1 month ago

rabol commented 2 months ago

Package

filament/filament

Package Version

v3.2.76

Laravel Version

v11.7.0

Livewire Version

No response

PHP Version

v8.3.6

Problem description

If you have a column on your model that is of type enum then the generated code by php artisan make:filament-resource UserResource -G is not correct.

this is generated

Tables\Columns\TextColumn::make('user_level')
                    ->numeric()
                    ->sortable(),

Expected behavior

That the code generated is valid and working.

Steps to reproduce

Use the repo, login select the users

Reproduction repository

https://github.com/rabol/filament-bug

Relevant log output

No response

giacomomasseron commented 1 month ago

I cloned your repo but this is the migration:

$table->integer('user_level')->default(0);

it's not an enum

rabol commented 1 month ago

On the model it’s casted to a enum, how would you otherwise do it?

it works in all other parts of the app

giacomomasseron commented 1 month ago

You could use the enum function of a migration.

IMHO seems more an enhancement, instead of a bug.

Filament gets database schema to create the list and the form. It does not check the laravel casts.

rabol commented 1 month ago

a boolean work even if it stored in the db as an int

zepfietje commented 1 month ago

This isn't a bug if the column is an integer in the database indeed.