All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 12s
118 lines
4.6 KiB
PHP
118 lines
4.6 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Imports;
|
|
|
|
use App\Models\CharacteristicApproverMaster;
|
|
use Filament\Actions\Imports\ImportColumn;
|
|
use Filament\Actions\Imports\Importer;
|
|
use Filament\Actions\Imports\Models\Import;
|
|
|
|
class CharacteristicApproverMasterImporter extends Importer
|
|
{
|
|
protected static ?string $model = CharacteristicApproverMaster::class;
|
|
|
|
public static function getColumns(): array
|
|
{
|
|
return [
|
|
ImportColumn::make('plant')
|
|
->requiredMapping()
|
|
->exampleHeader('Plant Code')
|
|
->examples(['1000','1000'])
|
|
->label('Plant Code')
|
|
->relationship(resolveUsing: 'code')
|
|
->rules(['required']),
|
|
ImportColumn::make('machine')
|
|
->requiredMapping()
|
|
->exampleHeader('Work Center')
|
|
->examples(['RMGLAS02','RMGLAS02'])
|
|
->label('Work Center')
|
|
->relationship()
|
|
->rules(['required']),
|
|
ImportColumn::make('machine_name')
|
|
->requiredMapping()
|
|
->exampleHeader('Machine Name')
|
|
->examples(['15002635','17002635'])
|
|
->label('Machine Name'),
|
|
ImportColumn::make('name1')
|
|
->requiredMapping()
|
|
->exampleHeader('Approver Name 1')
|
|
->examples(['Suresh.D','Suresh.D'])
|
|
->label('Approver Name 1'),
|
|
ImportColumn::make('mail1')
|
|
->requiredMapping()
|
|
->exampleHeader('Approver Mail 1')
|
|
->examples(['suresh@cripumps.com','suresh@cripumps.com'])
|
|
->label('Approver Mail 1'),
|
|
ImportColumn::make('name2')
|
|
->requiredMapping()
|
|
->exampleHeader('Approver Name 2')
|
|
->examples(['Ramesh.G','Ramesh.G'])
|
|
->label('Approver Name 2'),
|
|
ImportColumn::make('mail2')
|
|
->requiredMapping()
|
|
->exampleHeader('Approver Mail 2')
|
|
->examples(['ramesh@cripumps.com','ramesh@cripumps.com'])
|
|
->label('Approver Mail 2'),
|
|
ImportColumn::make('name3')
|
|
->requiredMapping()
|
|
->exampleHeader('Approver Name 3')
|
|
->examples(['Ganesh.K','Ganesh.K'])
|
|
->label('Approver Name 3'),
|
|
ImportColumn::make('mail3')
|
|
->requiredMapping()
|
|
->exampleHeader('Approver Mail 3')
|
|
->examples(['ganesh@cripumps.com','ganesh@cripumps.com'])
|
|
->label('Approver Mail 3'),
|
|
ImportColumn::make('duration1')
|
|
->numeric()
|
|
->requiredMapping()
|
|
->exampleHeader('Duration 1')
|
|
->examples(['0.05','0.30'])
|
|
->label('Duration 1'),
|
|
ImportColumn::make('duration2')
|
|
->numeric()
|
|
->requiredMapping()
|
|
->exampleHeader('Duration 2')
|
|
->examples(['0.05','0.30'])
|
|
->label('Duration 2'),
|
|
ImportColumn::make('duration3')
|
|
->numeric()
|
|
->requiredMapping()
|
|
->exampleHeader('Duration 3')
|
|
->examples(['0.05','0.30'])
|
|
->label('Duration 3'),
|
|
ImportColumn::make('characteristic_field')
|
|
->requiredMapping()
|
|
->exampleHeader('Characteristic Field')
|
|
->examples(['MV SERIES','PV SERIES'])
|
|
->label('Characteristic Field'),
|
|
ImportColumn::make('approver_type')
|
|
->requiredMapping()
|
|
->exampleHeader('Approver Type')
|
|
->examples(['Characteristic','Quality'])
|
|
->label('Approver Type'),
|
|
];
|
|
}
|
|
|
|
public function resolveRecord(): ?CharacteristicApproverMaster
|
|
{
|
|
// return CharacteristicApproverMaster::firstOrNew([
|
|
// // Update existing records, matching them by `$this->data['column_name']`
|
|
// 'email' => $this->data['email'],
|
|
// ]);
|
|
|
|
return new CharacteristicApproverMaster();
|
|
}
|
|
|
|
public static function getCompletedNotificationBody(Import $import): string
|
|
{
|
|
$body = 'Your characteristic approver master 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;
|
|
}
|
|
}
|