Refactor employee management by implementing automatic employee number generation, updating national ID handling, and enhancing localization for gender and nationality fields across various resources. Adjust form components and validation logic to improve user experience and data integrity.
This commit is contained in:
@@ -5,10 +5,11 @@ namespace App\Filament\Resources\Employees\Schemas;
|
||||
use App\Enums\EmploymentStatus;
|
||||
use App\Enums\Gender;
|
||||
use App\Filament\Support\HrForm;
|
||||
use App\Support\Countries;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
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;
|
||||
@@ -30,24 +31,32 @@ class EmployeeForm
|
||||
->imageEditor(),
|
||||
TextInput::make('employee_number')
|
||||
->label(__('hr.fields.employee_number'))
|
||||
->required()
|
||||
->maxLength(50)
|
||||
->unique(ignoreRecord: true),
|
||||
->disabled()
|
||||
->dehydrated(false)
|
||||
->visibleOn('edit'),
|
||||
TextInput::make('full_name')
|
||||
->label(__('hr.fields.full_name'))
|
||||
->required()
|
||||
->maxLength(255),
|
||||
TextInput::make('national_id')
|
||||
Select::make('national_id')
|
||||
->label(__('hr.fields.national_id'))
|
||||
->maxLength(50),
|
||||
->options(fn (): array => Countries::options())
|
||||
->searchable()
|
||||
->native(false)
|
||||
->default(Countries::default())
|
||||
->required(),
|
||||
|
||||
Select::make('gender')
|
||||
->label(__('hr.fields.gender'))
|
||||
->options(Gender::class)
|
||||
->required()
|
||||
->native(false),
|
||||
|
||||
DatePicker::make('birth_date')
|
||||
->label(__('hr.fields.birth_date'))
|
||||
->required(),
|
||||
->required()
|
||||
->native(false),
|
||||
|
||||
TextInput::make('phone')
|
||||
->label(__('hr.fields.phone'))
|
||||
->tel()
|
||||
|
||||
@@ -9,6 +9,7 @@ use App\Enums\Gender;
|
||||
use App\Models\Employee;
|
||||
use App\Models\Vacation;
|
||||
use App\Services\Employee\EmployeeStatisticsService;
|
||||
use App\Support\Countries;
|
||||
use Filament\Infolists\Components\ImageEntry;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Schemas\Components\Section;
|
||||
@@ -42,6 +43,7 @@ class EmployeeInfolist
|
||||
->label(__('hr.fields.full_name')),
|
||||
TextEntry::make('national_id')
|
||||
->label(__('hr.fields.national_id'))
|
||||
->formatStateUsing(fn (?string $state): string => Countries::name($state) ?? $state ?? '—')
|
||||
->placeholder('—'),
|
||||
TextEntry::make('gender')
|
||||
->label(__('hr.fields.gender'))
|
||||
@@ -153,16 +155,16 @@ class EmployeeInfolist
|
||||
TextEntry::make('leave_balance_taken')
|
||||
->label(__('hr.fields.days_taken'))
|
||||
->state(fn (Employee $record): int => app(EmployeeStatisticsService::class)->summary($record)->vacationTaken)
|
||||
->suffix(' ' . __('hr.messages.days_suffix')),
|
||||
->suffix(' '.__('hr.messages.days_suffix')),
|
||||
TextEntry::make('leave_balance_remaining')
|
||||
->label(__('hr.fields.days_remaining'))
|
||||
->state(fn (Employee $record): int => app(EmployeeStatisticsService::class)->summary($record)->vacationRemaining)
|
||||
->suffix(' ' . __('hr.messages.days_suffix'))
|
||||
->suffix(' '.__('hr.messages.days_suffix'))
|
||||
->color('success'),
|
||||
TextEntry::make('leave_balance_total')
|
||||
->label(__('hr.fields.annual_allowance'))
|
||||
->state(fn (): int => (int) config('hr.annual_leave_days'))
|
||||
->suffix(' ' . __('hr.messages.days_suffix')),
|
||||
->suffix(' '.__('hr.messages.days_suffix')),
|
||||
])
|
||||
->columns(3),
|
||||
Section::make(__('hr.sections.upcoming_approved_leave'))
|
||||
|
||||
Reference in New Issue
Block a user