From 65f8c8cfc9cb53b898b7d521ef8598643b738b9a Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Fri, 29 May 2026 20:21:45 +0530 Subject: [PATCH] Added exporter file --- .../Exports/LeakTestReadingExporter.php | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 app/Filament/Exports/LeakTestReadingExporter.php diff --git a/app/Filament/Exports/LeakTestReadingExporter.php b/app/Filament/Exports/LeakTestReadingExporter.php new file mode 100644 index 0000000..2711c5f --- /dev/null +++ b/app/Filament/Exports/LeakTestReadingExporter.php @@ -0,0 +1,64 @@ +label('NO') + ->state(function ($record) use (&$rowNumber) { + // Increment and return the row number + return ++$rowNumber; + }), + ExportColumn::make('plant.code') + ->label('PLANT CODE'), + ExportColumn::make('item_code') + ->label('ITEM CODE'), + ExportColumn::make('serial_number') + ->label('SERIAL NUMBER'), + ExportColumn::make('test_status') + ->label('TEST STATUS') + ->formatStateUsing(function ($state) { + if (! $state || $state == '' || $state == null) { + return '-'; + } + + return match ($state) { + 'P' => 'PASS', + 'F' => 'FAIL', + default => '-', + }; + }), + ExportColumn::make('created_at') + ->label('CREATED AT'), + ExportColumn::make('updated_at') + ->label('UPDATED AT'), + ExportColumn::make('deleted_at') + ->enabledByDefault(false) + ->label('DELETED AT'), + ]; + } + + public static function getCompletedNotificationBody(Export $export): string + { + $body = 'Your leak test reading export has completed and '.number_format($export->successful_rows).' '.str('row')->plural($export->successful_rows).' exported.'; + + if ($failedRowsCount = $export->getFailedRowsCount()) { + $body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to export.'; + } + + return $body; + } +}