Files
pds/app/Filament/Exports/TempStopCharacteristicResourceExporter.php
dhanabalan b5d6207e7e
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 14s
Added model masters importer and exporter files
2026-09-05 10:31:07 +05:30

80 lines
3.0 KiB
PHP

<?php
namespace App\Filament\Exports;
use App\Models\TempStopCharacteristicResource;
use Filament\Actions\Exports\ExportColumn;
use Filament\Actions\Exports\Exporter;
use Filament\Actions\Exports\Models\Export;
class TempStopCharacteristicResourceExporter extends Exporter
{
protected static ?string $model = TempStopCharacteristicResource::class;
public static function getColumns(): array
{
return [
// ExportColumn::make('id')
// ->label('ID'),
ExportColumn::make('no')
->label('NO')
->state(function ($record) use (&$rowNumber) {
// Increment and return the row number
return ++$rowNumber;
}),
ExportColumn::make('plant.code')
->label('PLANT CODE'),
ExportColumn::make('machine.work_center')
->label('WORK CENTER'),
ExportColumn::make('machine_name')
->label('MACHINE NAME'),
ExportColumn::make('has_stop_flow_id')
->label('HAS STOP FLOW ID'),
ExportColumn::make('item.code')
->label('ITEM CODE'),
ExportColumn::make('aufnr')
->label('JOB NUMBER'),
ExportColumn::make('gernr')
->label('SERIAL NUMBER'),
ExportColumn::make('zmm_heading')
->label('ZMM HEADING'),
ExportColumn::make('winded_serial_number')
->label('WINDED SERIAL NUMBER'),
ExportColumn::make('model_type')
->label('MODEL TYPE'),
ExportColumn::make('characteristic_field')
->label('MASTER CHARACTERISTIC FIELD'),
ExportColumn::make('samlight_logged_name')
->label('SAMLIGHT LOGGED NAME'),
ExportColumn::make('stopped_at')
->label('STOPPED AT'),
ExportColumn::make('stopped_by')
->label('STOPPED BY'),
ExportColumn::make('has_stop_flow_id')
->label('HAS STOP FLOW ID'),
ExportColumn::make('created_at')
->label('CREATED AT'),
ExportColumn::make('created_by')
->label('CREATED BY'),
ExportColumn::make('updated_at')
->label('UPDATED AT'),
ExportColumn::make('updated_by')
->label('UPDATED BY'),
ExportColumn::make('deleted_at')
->enabledByDefault(false)
->label('DELETED AT'),
];
}
public static function getCompletedNotificationBody(Export $export): string
{
$body = 'Your temp stop characteristic resource 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;
}
}