Files
hr/app/Filament/Resources/Vacations/Schemas/VacationInfolist.php

91 lines
4.1 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Filament\Resources\Vacations\Schemas;
use App\Enums\ApprovalStatus;
use App\Enums\VacationType;
use App\Models\Vacation;
use Filament\Infolists\Components\ImageEntry;
use Filament\Infolists\Components\TextEntry;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Schema;
class VacationInfolist
{
public static function configure(Schema $schema): Schema
{
return $schema
->components([
Section::make(__('hr.sections.basic_info'))
->schema([
TextEntry::make('employee.full_name')
->label(__('hr.fields.employee')),
TextEntry::make('type')
->label(__('hr.fields.type'))
->badge()
->color(fn (VacationType $state): string => $state->color())
->formatStateUsing(fn (VacationType $state): string => $state->label()),
TextEntry::make('status')
->label(__('hr.fields.status'))
->badge()
->color(fn (ApprovalStatus $state): string => $state->color())
->formatStateUsing(fn (ApprovalStatus $state): string => $state->label()),
])
->columns(3),
Section::make(__('hr.sections.dates'))
->schema([
TextEntry::make('start_date')
->label(__('hr.fields.start_date'))
->date('d.m.Y'),
TextEntry::make('end_date')
->label(__('hr.fields.end_date'))
->date('d.m.Y'),
TextEntry::make('return_date')
->label(__('hr.fields.return_date'))
->date('d.m.Y')
->placeholder('—'),
TextEntry::make('days')
->label(__('hr.fields.days'))
->suffix(' '.__('hr.messages.days_suffix')),
])
->columns(2),
Section::make(__('hr.sections.approval'))
->schema([
TextEntry::make('reason')
->label(__('hr.fields.reason'))
->placeholder('—')
->columnSpanFull(),
TextEntry::make('attachment_path')
->label(__('hr.fields.attachment'))
->formatStateUsing(fn (?string $state): string => filled($state) ? basename($state) : '—'),
TextEntry::make('approved_by')
->label(__('hr.fields.approved_by'))
->formatStateUsing(fn ($state, Vacation $record): string => $record->approver?->name ?? '—'),
])
->columns(2),
Section::make(__('hr.sections.metadata'))
->schema([
TextEntry::make('approved_at')
->label(__('hr.fields.approved_at'))
->dateTime('d.m.Y H:i')
->placeholder('—'),
TextEntry::make('created_at')
->label(__('hr.fields.created_at'))
->dateTime('d.m.Y H:i')
->placeholder('—'),
TextEntry::make('updated_at')
->label(__('hr.fields.updated_at'))
->dateTime('d.m.Y H:i')
->placeholder('—'),
TextEntry::make('deleted_at')
->label(__('hr.fields.deleted_at'))
->dateTime('d.m.Y H:i')
->visible(fn (Vacation $record): bool => $record->trashed()),
])
->columns(2),
]);
}
}