Files
hr/app/Filament/Support/ExportPdfAction.php
2026-07-31 18:08:08 +05:00

56 lines
1.9 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Filament\Support;
use App\Models\Employee;
use App\Services\Export\PdfExportService;
use Filament\Actions\Action;
use Filament\Actions\BulkAction;
use Illuminate\Database\Eloquent\Collection;
class ExportPdfAction
{
public static function employeeProfile(): Action
{
return Action::make('exportPdf')
->label(__('hr.actions.export_pdf'))
->icon('heroicon-o-document-arrow-down')
->action(fn (Employee $record, PdfExportService $pdf) => $pdf->employeeProfile($record));
}
public static function employeeLeaveSummary(): Action
{
return Action::make('exportLeavePdf')
->label(__('hr.actions.leave_summary_pdf'))
->icon('heroicon-o-document-text')
->action(fn (Employee $record, PdfExportService $pdf) => $pdf->leaveSummary($record));
}
public static function employeeList(): Action
{
return Action::make('exportPdf')
->label(__('hr.actions.export_pdf'))
->icon('heroicon-o-document-arrow-down')
->action(fn (PdfExportService $pdf) => $pdf->employeeList(
Employee::query()->with(['department', 'position', 'shift'])->orderBy('full_name')->get()
));
}
public static function employeeListBulk(): BulkAction
{
return BulkAction::make('exportPdf')
->label(__('hr.actions.export_pdf'))
->icon('heroicon-o-document-arrow-down')
->action(fn (Collection $records, PdfExportService $pdf) => $pdf->employeeList(
Employee::query()
->with(['department', 'position', 'shift'])
->whereIn('id', $records->pluck('id'))
->orderBy('full_name')
->get()
))
->deselectRecordsAfterCompletion();
}
}