On this page
Has Enums
Config File
first, provide an array in your config file, contain the enum names as a key, and its value will be the full path: For example, let say you plugin needs two enums, the user type enum and a status enums:
1/**2 * you can overwrite any enum and use your own3 * you can also configure the enum per panel in your panel provider4 * using: ->enums([ ... ])5 */6'enums' => [7 'UserType' => \LaraZeus\Package\Enums\UserType::class,8 'Status' => \LaraZeus\Delia\Package\Status::class,9],
This way, your users can configure the enums per panel or globally from the config file:
1public function panel(Panel $panel): Panel 2{ 3 return $panel 4 // ... 5 ->plugins([ 6 MyAwesomePlugin::make() 7 ->enums([ 8 'UserType' => \LaraZeus\Package\Enums\UserType::class 9 //...10 ]),11 ]);12}
with this approach, FilamentPluginTools
will merge the enums from the config file, and what the user provide per panel.
now, in your plugin, you can use it like:
1MyAwesomePlugin::getEnum('UserType')