Files
pds/app/Filament/Imports/CourierOutwardImporter.php
dhanabalan af7b60da26
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Failing after 1m19s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 19s
Laravel Pint / pint (pull_request) Successful in 2m31s
Laravel Larastan / larastan (pull_request) Failing after 6m8s
Added courier outward importer and exporter page
2026-11-06 16:33:48 +05:30

55 lines
1.8 KiB
PHP

<?php
namespace App\Filament\Imports;
use App\Models\CourierOutward;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
class CourierOutwardImporter extends Importer
{
protected static ?string $model = CourierOutward::class;
public static function getColumns(): array
{
return [
ImportColumn::make('plant')
->requiredMapping()
->relationship()
->rules(['required']),
ImportColumn::make('date')
->rules(['date']),
ImportColumn::make('to_address'),
ImportColumn::make('cover_material'),
ImportColumn::make('name_of_sender'),
ImportColumn::make('place_pincode'),
ImportColumn::make('pod_number'),
ImportColumn::make('remark'),
ImportColumn::make('created_by'),
ImportColumn::make('updated_by'),
];
}
public function resolveRecord(): ?CourierOutward
{
// return CourierOutward::firstOrNew([
// // Update existing records, matching them by `$this->data['column_name']`
// 'email' => $this->data['email'],
// ]);
return new CourierOutward();
}
public static function getCompletedNotificationBody(Import $import): string
{
$body = 'Your courier outward 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;
}
}