Implement HasLabel interface in multiple enum classes, refactor label methods to improve localization consistency, and update default phone configuration in HR settings. Enhance employee form with phone number formatting and localization tests for enum options.
This commit is contained in:
1 parent
eed46157cd
commit
e16402b23f
13 files changed
+102
-26
No files matched your search
@@ -4,13 +4,15 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum ApprovalStatus: string
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
enum ApprovalStatus: string implements HasLabel
|
||||
{
|
||||
case Pending = 'pending';
|
||||
case Approved = 'approved';
|
||||
case Rejected = 'rejected';
|
||||
|
||||
public function label(): string
|
||||
public function getLabel(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Pending => __('enums.approval_status.pending'),
|
||||
@@ -19,6 +21,11 @@ public function label(): string
|
||||
};
|
||||
}
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return $this->getLabel();
|
||||
}
|
||||
|
||||
public function color(): string
|
||||
{
|
||||
return match ($this) {
|
||||
|
||||
@@ -4,14 +4,16 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum BonusType: string
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
enum BonusType: string implements HasLabel
|
||||
{
|
||||
case Performance = 'performance';
|
||||
case Holiday = 'holiday';
|
||||
case Retention = 'retention';
|
||||
case Other = 'other';
|
||||
|
||||
public function label(): string
|
||||
public function getLabel(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Performance => __('enums.bonus_type.performance'),
|
||||
@@ -21,6 +23,11 @@ public function label(): string
|
||||
};
|
||||
}
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return $this->getLabel();
|
||||
}
|
||||
|
||||
public function color(): string
|
||||
{
|
||||
return match ($this) {
|
||||
|
||||
@@ -4,13 +4,15 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum DisciplinarySeverity: string
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
enum DisciplinarySeverity: string implements HasLabel
|
||||
{
|
||||
case Low = 'low';
|
||||
case Medium = 'medium';
|
||||
case High = 'high';
|
||||
|
||||
public function label(): string
|
||||
public function getLabel(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Low => __('enums.disciplinary_severity.low'),
|
||||
@@ -19,6 +21,11 @@ public function label(): string
|
||||
};
|
||||
}
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return $this->getLabel();
|
||||
}
|
||||
|
||||
public function color(): string
|
||||
{
|
||||
return match ($this) {
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum DocumentType: string
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
enum DocumentType: string implements HasLabel
|
||||
{
|
||||
case Passport = 'passport';
|
||||
case Contract = 'contract';
|
||||
@@ -12,7 +14,7 @@ enum DocumentType: string
|
||||
case EducationCertificate = 'education_certificate';
|
||||
case Other = 'other';
|
||||
|
||||
public function label(): string
|
||||
public function getLabel(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Passport => __('enums.document_type.passport'),
|
||||
@@ -23,6 +25,11 @@ public function label(): string
|
||||
};
|
||||
}
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return $this->getLabel();
|
||||
}
|
||||
|
||||
public function color(): string
|
||||
{
|
||||
return match ($this) {
|
||||
|
||||
@@ -4,14 +4,16 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum EmploymentStatus: string
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
enum EmploymentStatus: string implements HasLabel
|
||||
{
|
||||
case Active = 'active';
|
||||
case Inactive = 'inactive';
|
||||
case Terminated = 'terminated';
|
||||
case OnLeave = 'on_leave';
|
||||
|
||||
public function label(): string
|
||||
public function getLabel(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Active => __('enums.employment_status.active'),
|
||||
@@ -21,6 +23,11 @@ public function label(): string
|
||||
};
|
||||
}
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return $this->getLabel();
|
||||
}
|
||||
|
||||
public function color(): string
|
||||
{
|
||||
return match ($this) {
|
||||
|
||||
@@ -4,13 +4,15 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum Gender: string
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
enum Gender: string implements HasLabel
|
||||
{
|
||||
case Male = 'male';
|
||||
case Female = 'female';
|
||||
// case Other = 'other';
|
||||
|
||||
public function label(): string
|
||||
public function getLabel(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Male => __('enums.gender.male'),
|
||||
@@ -19,6 +21,11 @@ public function label(): string
|
||||
};
|
||||
}
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return $this->getLabel();
|
||||
}
|
||||
|
||||
public function color(): string
|
||||
{
|
||||
return match ($this) {
|
||||
|
||||
@@ -4,14 +4,16 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum ImportType: string
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
enum ImportType: string implements HasLabel
|
||||
{
|
||||
case Employees = 'employees';
|
||||
case Vacations = 'vacations';
|
||||
case Bonuses = 'bonuses';
|
||||
case Reports = 'reports';
|
||||
|
||||
public function label(): string
|
||||
public function getLabel(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Employees => __('enums.import_type.employees'),
|
||||
@@ -21,6 +23,11 @@ public function label(): string
|
||||
};
|
||||
}
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return $this->getLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
|
||||
@@ -4,14 +4,16 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum VacationType: string
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
enum VacationType: string implements HasLabel
|
||||
{
|
||||
case Annual = 'annual';
|
||||
case Marriage = 'marriage';
|
||||
case Study = 'study';
|
||||
case Other = 'other';
|
||||
|
||||
public function label(): string
|
||||
public function getLabel(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Annual => __('enums.vacation_type.annual'),
|
||||
@@ -21,6 +23,11 @@ public function label(): string
|
||||
};
|
||||
}
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return $this->getLabel();
|
||||
}
|
||||
|
||||
public function color(): string
|
||||
{
|
||||
return match ($this) {
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
|
||||
use App\Enums\EmploymentStatus;
|
||||
use App\Enums\Gender;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Support\RawJs;
|
||||
use App\Filament\Support\HrForm;
|
||||
use App\Support\Countries;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use App\Support\Countries;use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Components\Tabs;
|
||||
use Filament\Schemas\Components\Tabs\Tab;
|
||||
use Filament\Schemas\Schema;
|
||||
@@ -59,9 +59,12 @@ public static function configure(Schema $schema): Schema
|
||||
|
||||
TextInput::make('phone')
|
||||
->label(__('hr.fields.phone'))
|
||||
->tel()
|
||||
->default(config('hr.default_phone'))
|
||||
->prefix('+993')
|
||||
->mask(RawJs::make(<<<'JS'
|
||||
'99 99-99-99'
|
||||
JS))
|
||||
->required(),
|
||||
|
||||
Textarea::make('address')
|
||||
->label(__('hr.fields.address'))
|
||||
->rows(3)
|
||||
|
||||
Reference in new issue
Block a user