Change plural name dynamically
Hi i want to change my plural name for the resource based on an enum I have set up. I have checked the docs and seen I can load it dynamically
public static function getModelLabel(): string
{
return __('filament/resources/customer.label');
}
I am a bit stumped if Filamnet has this directory made already or I need to create it myself?
Thanks
So are you sayin that you have a vehicles resource, but instead you want to call it cars?
@Tray2 Hi, I sorted it I used the Laravel lang and did some code to show different names for different states based on the enum, thanks
public static function getPluralModelLabel(): string
{
$user = Auth::user();
if ($user instanceof User) {
if ($user->isAdmin()) {
return __('filament.resources.application.plural_admin');
}
$application = $user->application;
if ($application && $application->status === ApplicationStatusEnum::APPROVED) {
return __('filament.resources.application.plural_approved');
}
}
return __('filament.resources.application.plural');
}
@Tray2 Ah ok,
- is the rest of the code using __() ok? I need to tap into the enum value.
- Would using __() instead of a Str::plural cause any issues? I just want to understand why it's better to go with Str::.
Thanks for the help.
@Cushty It does it automatically for you, so you don't have to write the enums containing the different values.
Please or to participate in this conversation.