Added model masters importer and exporter files
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 14s
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 14s
This commit is contained in:
115
app/Filament/Imports/TempStopCharacteristicResourceImporter.php
Normal file
115
app/Filament/Imports/TempStopCharacteristicResourceImporter.php
Normal file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\TempStopCharacteristicResource;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
|
||||
class TempStopCharacteristicResourceImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = TempStopCharacteristicResource::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->label('PLANT CODE')
|
||||
->exampleHeader('PLANT CODE')
|
||||
->example('1000')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('machine')
|
||||
->requiredMapping()
|
||||
->label('WORK CENTER')
|
||||
->exampleHeader('WORK CENTER')
|
||||
->example('RMGLAS01')
|
||||
->relationship(resolveUsing: 'work_center')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('machine_name')
|
||||
->label('MACHINE NAME')
|
||||
->exampleHeader('MACHINE NAME')
|
||||
->example('RMGLAS01')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('item')
|
||||
->requiredMapping()
|
||||
->exampleHeader('ITEM CODE')
|
||||
->example('630214')
|
||||
->label('ITEM CODE')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('aufnr')
|
||||
->label('JOB NUMBER')
|
||||
->exampleHeader('JOB NUMBER')
|
||||
->example('1234567'),
|
||||
ImportColumn::make('gernr')
|
||||
->label('SERIAL NUMBER')
|
||||
->exampleHeader('SERIAL NUMBER')
|
||||
->example('1234567890123'),
|
||||
ImportColumn::make('zmm_heading')
|
||||
->exampleHeader('ZMM HEADING')
|
||||
->example('ZMM001')
|
||||
->label('ZMM HEADING'),
|
||||
ImportColumn::make('winded_serial_number')
|
||||
->exampleHeader('WINDED SERIAL NUMBER')
|
||||
->example('WSN001')
|
||||
->label('WINDED SERIAL NUMBER'),
|
||||
ImportColumn::make('model_type')
|
||||
->label('MODEL TYPE')
|
||||
->exampleHeader('MODEL TYPE')
|
||||
->example('PUMP'),
|
||||
ImportColumn::make('characteristic_field')
|
||||
->label('MASTER CHARACTERISTIC FIELD')
|
||||
->exampleHeader('MASTER CHARACTERISTIC FIELD')
|
||||
->example('NIL'),
|
||||
ImportColumn::make('samlight_logged_name')
|
||||
->label('SAMLIGHT LOGGED NAME')
|
||||
->exampleHeader('SAMLIGHT LOGGED NAME')
|
||||
->example('User'),
|
||||
ImportColumn::make('stopped_at')
|
||||
->label('STOPPED AT')
|
||||
->exampleHeader('STOPPED AT')
|
||||
->example('01-09-2026 12:00:00')
|
||||
->rules(['datetime']),
|
||||
ImportColumn::make('stopped_by')
|
||||
->label('STOPPED BY')
|
||||
->exampleHeader('STOPPED BY')
|
||||
->example('RAW01234'),
|
||||
ImportColumn::make('has_stop_flow_id')
|
||||
->label('HAS STOP FLOW ID')
|
||||
->exampleHeader('HAS STOP FLOW ID')
|
||||
->example('2'),
|
||||
ImportColumn::make('created_by')
|
||||
->label('CREATED BY')
|
||||
->exampleHeader('CREATED BY')
|
||||
->example('RAW01234'),
|
||||
ImportColumn::make('updated_by')
|
||||
->label('UPDATED BY')
|
||||
->exampleHeader('UPDATED BY')
|
||||
->example('RAW01234'),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?TempStopCharacteristicResource
|
||||
{
|
||||
// return TempStopCharacteristicResource::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new TempStopCharacteristicResource;
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your temp stop characteristic resource import has completed and '.number_format($import->successful_rows).' '.str('row')->plural($import->successful_rows).' imported.';
|
||||
|
||||
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
||||
$body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to import.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user