Add HR resource labels and helper methods for various resources; update locale handling in user model and department factory
This commit is contained in:
30
app/Filament/Concerns/HasHrResourceLabels.php
Normal file
30
app/Filament/Concerns/HasHrResourceLabels.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Filament\Concerns;
|
||||
|
||||
trait HasHrResourceLabels
|
||||
{
|
||||
/**
|
||||
* @return array{model: string, plural: string, navigation?: string}
|
||||
*/
|
||||
abstract protected static function hrLabelKeys(): array;
|
||||
|
||||
public static function getModelLabel(): string
|
||||
{
|
||||
return __('hr.resources.'.static::hrLabelKeys()['model']);
|
||||
}
|
||||
|
||||
public static function getPluralModelLabel(): string
|
||||
{
|
||||
return __('hr.resources.'.static::hrLabelKeys()['plural']);
|
||||
}
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
$keys = static::hrLabelKeys();
|
||||
|
||||
return __('hr.resources.'.($keys['navigation'] ?? $keys['plural']));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user