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

Select field on enum type when using generate #15218

Open
wants to merge 9 commits into
base: 4.x
Choose a base branch
from

Conversation

achyutkneupane
Copy link

Description

When using --generate with php artisan make:filament-resource, enum table type will generate Forms\Components\Select.

Along with:

  • options from allowed array
  • Default value

It follows the basic label transformation script (kebab -> replace -> ucfirst) for options.

Visual changes

image

image

image

Functional changes

  • Code style has been fixed by running the composer cs command.
  • Changes have been tested to not break existing functionality.
  • Documentation is up-to-date.

@danharrin danharrin added this to the v4 milestone Jan 2, 2025
Copy link
Member

@danharrin danharrin left a comment

Choose a reason for hiding this comment

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

Usually people also pair this with an enum Eloquent model cast, or even use the enum class instead of an enum column. How about detecting on the model if an enum cast is used, and if it is pass the enum class name to the ->options()? And if there is no enum cast and the column is an enum type, then do this instead.

@achyutkneupane
Copy link
Author

achyutkneupane commented Jan 2, 2025

@danharrin I went through a lot of research on how to set class as an argument.

Thanks to the Literal import you used below, I got the idea.

Copy link
Author

@achyutkneupane achyutkneupane left a comment

Choose a reason for hiding this comment

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

@danharrin Can you verify the changes?

@danharrin
Copy link
Member

Thanks, I will take on the changes from here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

2 participants