after production line stop reason column remove
This commit is contained in:
78
app/Filament/Imports/ShiftImporter.php
Normal file
78
app/Filament/Imports/ShiftImporter.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\Shift;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
|
||||
class ShiftImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = Shift::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('name')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Shift Name')
|
||||
->label('Shift Name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('block')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Block Name')
|
||||
->label('Block Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('start_time')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Start Time')
|
||||
->label('Start Time')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('duration')
|
||||
->requiredMapping()
|
||||
->numeric()
|
||||
->exampleHeader('Shift Duration')
|
||||
->label('Shift Duration')
|
||||
->rules(['required', 'integer']),
|
||||
ImportColumn::make('end_time')
|
||||
->requiredMapping()
|
||||
->exampleHeader('End Time')
|
||||
->label('End Time')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('status')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Active Status')
|
||||
->label('Active Status')
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?Shift
|
||||
{
|
||||
// return Shift::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new Shift();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your shift 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