Added model masters resources, importer, and exporter files
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
This commit is contained in:
79
app/Filament/Exports/ModelMasterExporter.php
Normal file
79
app/Filament/Exports/ModelMasterExporter.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\ModelMaster;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class ModelMasterExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = ModelMaster::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
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('heading_name')
|
||||
->label('HEADING NAME'),
|
||||
ExportColumn::make('heading_value')
|
||||
->label('HEADING VALUE'),
|
||||
ExportColumn::make('type_name')
|
||||
->label('TYPE NAME'),
|
||||
ExportColumn::make('type_value')
|
||||
->label('TYPE VALUE'),
|
||||
ExportColumn::make('has_motor')
|
||||
->label('HAS MOTOR'),
|
||||
ExportColumn::make('has_m_part')
|
||||
->label('HAS MOTOR PART'),
|
||||
ExportColumn::make('has_m_count')
|
||||
->label('HAS MOTOR COUNT'),
|
||||
ExportColumn::make('has_pump')
|
||||
->label('HAS PUMP'),
|
||||
ExportColumn::make('has_p_part')
|
||||
->label('HAS PUMP PART'),
|
||||
ExportColumn::make('has_p_count')
|
||||
->label('HAS PUMP COUNT'),
|
||||
ExportColumn::make('has_name_plate')
|
||||
->label('HAS NAME PLATE'),
|
||||
ExportColumn::make('has_np_part')
|
||||
->label('HAS NAME PLATE PART'),
|
||||
ExportColumn::make('has_np_count')
|
||||
->label('HAS NAME PLATE COUNT'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT')
|
||||
->enabledByDefault(true),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY')
|
||||
->enabledByDefault(true),
|
||||
ExportColumn::make('deleted_at')
|
||||
->label('DELETED AT')
|
||||
->enabledByDefault(false),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your model master 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user