diff --git a/app/Filament/Exports/CourierOutwardExporter.php b/app/Filament/Exports/CourierOutwardExporter.php new file mode 100644 index 00000000..44f5ecf6 --- /dev/null +++ b/app/Filament/Exports/CourierOutwardExporter.php @@ -0,0 +1,45 @@ +label('ID'), + ExportColumn::make('plant.name'), + ExportColumn::make('date'), + ExportColumn::make('to_address'), + ExportColumn::make('cover_material'), + ExportColumn::make('name_of_sender'), + ExportColumn::make('place_pincode'), + ExportColumn::make('pod_number'), + ExportColumn::make('remark'), + ExportColumn::make('created_at'), + ExportColumn::make('updated_at'), + ExportColumn::make('created_by'), + ExportColumn::make('updated_by'), + ExportColumn::make('deleted_at'), + ]; + } + + public static function getCompletedNotificationBody(Export $export): string + { + $body = 'Your courier outward export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.'; + + if ($failedRowsCount = $export->getFailedRowsCount()) { + $body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.'; + } + + return $body; + } +} diff --git a/app/Filament/Imports/CourierOutwardImporter.php b/app/Filament/Imports/CourierOutwardImporter.php new file mode 100644 index 00000000..a6a9763c --- /dev/null +++ b/app/Filament/Imports/CourierOutwardImporter.php @@ -0,0 +1,54 @@ +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; + } +}