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