Files
pds/app/Filament/Imports/StickerMappingMasterImporter.php
dhanabalan 226d91ec6e
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Added sticker mapping master importer and exporter
2026-08-04 15:48:18 +05:30

56 lines
1.8 KiB
PHP

<?php
namespace App\Filament\Imports;
use App\Models\StickerMappingMaster;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
class StickerMappingMasterImporter extends Importer
{
protected static ?string $model = StickerMappingMaster::class;
public static function getColumns(): array
{
return [
ImportColumn::make('plant_id')
->requiredMapping()
->numeric()
->rules(['required', 'integer']),
ImportColumn::make('item')
->requiredMapping()
->relationship()
->rules(['required']),
ImportColumn::make('sticker1'),
ImportColumn::make('sticker2'),
ImportColumn::make('sticker3'),
ImportColumn::make('sticker4'),
ImportColumn::make('sticker5'),
ImportColumn::make('created_by'),
ImportColumn::make('updated_by'),
];
}
public function resolveRecord(): ?StickerMappingMaster
{
// return StickerMappingMaster::firstOrNew([
// // Update existing records, matching them by `$this->data['column_name']`
// 'email' => $this->data['email'],
// ]);
return new StickerMappingMaster();
}
public static function getCompletedNotificationBody(Import $import): string
{
$body = 'Your sticker mapping 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;
}
}