components([ Select::make('type') ->options(VacationType::class) ->required() ->native(false), HrForm::leaveDatePicker('start_date', __(hr.fields.start_date)), HrForm::leaveDatePicker('end_date', __(hr.fields.end_date)), DatePicker::make('return_date') ->label(__('hr.fields.return_date')), HrForm::leaveDaysDisplay(), Textarea::make('reason') ->rows(3) ->columnSpanFull(), HrForm::fileUpload('attachment_path') ->label(__('hr.fields.attachment')) ->acceptedFileTypes(['application/pdf', 'image/*']) ->maxSize(10240), ]); } public function table(Table $table): Table { return $table ->recordTitleAttribute('start_date') ->columns([ TextColumn::make('type') ->badge() ->color(fn (VacationType $state): string => $state->color()) ->formatStateUsing(fn (VacationType $state): string => $state->label()) ->sortable(), TextColumn::make('start_date') ->date() ->sortable(), TextColumn::make('end_date') ->date() ->sortable(), TextColumn::make('days') ->numeric() ->sortable(), TextColumn::make('status') ->badge() ->color(fn (ApprovalStatus $state): string => $state->color()) ->formatStateUsing(fn (ApprovalStatus $state): string => $state->label()) ->sortable(), TextColumn::make('approver.name') ->label(__('hr.fields.approved_by')) ->toggleable(isToggledHiddenByDefault: true), ]) ->filters([ SelectFilter::make('status') ->options(ApprovalStatus::class), SelectFilter::make('type') ->options(VacationType::class), TrashedFilter::make(), ]) ->headerActions([ CreateAction::make(), ]) ->recordActions([ Action::make('approve') ->label(__('hr.actions.approve')) ->icon('heroicon-o-check-badge') ->color('success') ->requiresConfirmation() ->visible(fn (Vacation $record): bool => $record->status === ApprovalStatus::Pending) ->action(function (Vacation $record, VacationService $vacationService): void { $vacationService->approve($record, Auth::user()); }), Action::make('reject') ->label(__('hr.actions.reject')) ->icon('heroicon-o-x-mark') ->color('danger') ->requiresConfirmation() ->visible(fn (Vacation $record): bool => $record->status === ApprovalStatus::Pending) ->action(function (Vacation $record, VacationService $vacationService): void { $vacationService->reject($record, Auth::user()); }), EditAction::make(), DeleteAction::make(), ]) ->toolbarActions([ BulkActionGroup::make([ DeleteBulkAction::make(), ForceDeleteBulkAction::make(), RestoreBulkAction::make(), ]), ]); } }