Added panel box validation importer and exporter
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 42s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 34s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 30s
Laravel Pint / pint (pull_request) Successful in 1m55s
Laravel Larastan / larastan (pull_request) Failing after 5m20s
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 42s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 34s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 30s
Laravel Pint / pint (pull_request) Successful in 1m55s
Laravel Larastan / larastan (pull_request) Failing after 5m20s
This commit is contained in:
87
app/Filament/Exports/PanelBoxValidationExporter.php
Normal file
87
app/Filament/Exports/PanelBoxValidationExporter.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\PanelBoxValidation;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class PanelBoxValidationExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = PanelBoxValidation::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
return [
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT NAME'),
|
||||
ExportColumn::make('line.name')
|
||||
->label('LINE NAME'),
|
||||
ExportColumn::make('stickerMaster.item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('production_order')
|
||||
->label('PRODUCTION ORDER'),
|
||||
ExportColumn::make('inspection_lot_number')
|
||||
->label('INSPECTION LOT NUMBER'),
|
||||
ExportColumn::make('serial_number')
|
||||
->label('SERIAL NUMBER'),
|
||||
ExportColumn::make('panel_box_supplier')
|
||||
->label('PANEL BOX SUPPLIER'),
|
||||
ExportColumn::make('panel_box_serial_number')
|
||||
->label('PANEL BOX SERIAL NUMBER'),
|
||||
ExportColumn::make('panel_box_code')
|
||||
->label('PANEL BOX CODE'),
|
||||
ExportColumn::make('serial_number_panel')
|
||||
->label('SERIAL NUMBER PANEL'),
|
||||
ExportColumn::make('pack_slip_panel')
|
||||
->label('PACK SLIP PANEL'),
|
||||
ExportColumn::make('name_plate_panel')
|
||||
->label('NAME PLATE PANEL'),
|
||||
ExportColumn::make('tube_sticker_panel')
|
||||
->label('TUBE STICKER PANEL'),
|
||||
ExportColumn::make('warranty_card_panel')
|
||||
->label('WARRANTY CARD PANEL'),
|
||||
ExportColumn::make('part_validation1')
|
||||
->label('PART VALIDATION 1'),
|
||||
ExportColumn::make('part_validation2')
|
||||
->label('PART VALIDATION 2'),
|
||||
ExportColumn::make('part_validation3')
|
||||
->label('PART VALIDATION 3'),
|
||||
ExportColumn::make('part_validation4')
|
||||
->label('PART VALIDATION 4'),
|
||||
ExportColumn::make('part_validation5')
|
||||
->label('PART VALIDATION 5'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->label('DELETED AT')
|
||||
->enabledByDefault(false),
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your panel box validation 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;
|
||||
}
|
||||
}
|
||||
70
app/Filament/Imports/PanelBoxValidationImporter.php
Normal file
70
app/Filament/Imports/PanelBoxValidationImporter.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\PanelBoxValidation;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
|
||||
class PanelBoxValidationImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = PanelBoxValidation::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->relationship()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('line')
|
||||
->requiredMapping()
|
||||
->relationship()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('stickerMaster')
|
||||
->requiredMapping()
|
||||
->relationship()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('production_order'),
|
||||
ImportColumn::make('serial_number'),
|
||||
ImportColumn::make('serial_number_panel'),
|
||||
ImportColumn::make('pack_slip_panel'),
|
||||
ImportColumn::make('name_plate_panel'),
|
||||
ImportColumn::make('tube_sticker_panel'),
|
||||
ImportColumn::make('warranty_card_panel'),
|
||||
ImportColumn::make('part_validation1'),
|
||||
ImportColumn::make('part_validation2'),
|
||||
ImportColumn::make('part_validation3'),
|
||||
ImportColumn::make('part_validation4'),
|
||||
ImportColumn::make('part_validation5'),
|
||||
ImportColumn::make('created_by'),
|
||||
ImportColumn::make('updated_by'),
|
||||
ImportColumn::make('panel_box_supplier'),
|
||||
ImportColumn::make('panel_box_serial_number'),
|
||||
ImportColumn::make('panel_box_code'),
|
||||
ImportColumn::make('inspection_lot_number'),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?PanelBoxValidation
|
||||
{
|
||||
// return PanelBoxValidation::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new PanelBoxValidation();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your panel box validation 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