Added required mapping for import columns and Updated plant selection logic in various resources on Advanced Filters

This commit is contained in:
dhanabalan
2025-10-08 17:46:19 +05:30
parent 377fd4c615
commit 98dc59538f
16 changed files with 177 additions and 123 deletions

View File

@@ -26,107 +26,107 @@ class StickerMasterImporter extends Importer
->relationship(resolveUsing: 'code')
->rules(['required']),
ImportColumn::make('serial_number_motor')
// ->requiredMapping()
->requiredMapping()
->exampleHeader('Serial Number Motor')
->label('SERIAL NUMBER MOTOR')
->example('1'),
ImportColumn::make('serial_number_pump')
//->requiredMapping()
->requiredMapping()
->exampleHeader('Serial Number Pump')
->label('SERIAL NUMBER PUMP')
->example('1'),
ImportColumn::make('serial_number_pumpset')
//->requiredMapping()
->requiredMapping()
->exampleHeader('Serial Number PumpSet')
->label('SERIAL NUMBER PUMPSET')
->example(''),
ImportColumn::make('pack_slip_motor')
//->requiredMapping()
->requiredMapping()
->exampleHeader('Pack Slip Motor')
->label('PACK SLIP MOTOR')
->example('1'),
ImportColumn::make('pack_slip_pump')
//->requiredMapping()
->requiredMapping()
->exampleHeader('Pack Slip Pump')
->label('PACK SLIP PUMP')
->example('1'),
ImportColumn::make('pack_slip_pumpset')
//->requiredMapping()
->requiredMapping()
->exampleHeader('Pack Slip PumpSet')
->label('PACK SLIP PUMPSET')
->example(''),
ImportColumn::make('name_plate_motor')
// ->requiredMapping()
->requiredMapping()
->exampleHeader('Name Plate Motor')
->label('NAME PLATE MOTOR')
->example('1'),
ImportColumn::make('name_plate_pump')
// ->requiredMapping()
->requiredMapping()
->exampleHeader('Name Plate Pump')
->label('NAME PLATE PUMP')
->example('1'),
ImportColumn::make('name_plate_pumpset')
// ->requiredMapping()
->requiredMapping()
->exampleHeader('Name Plate PumpSet')
->label('NAME PLATE PUMPSET')
->example(''),
ImportColumn::make('tube_sticker_motor')
// ->requiredMapping()
->requiredMapping()
->exampleHeader('Tube Sticker Motor')
->label('TUBE STICKER MOTOR')
->example('1'),
ImportColumn::make('tube_sticker_pump')
// ->requiredMapping()
->requiredMapping()
->exampleHeader('Tube Sticker Pump')
->label('TUBE STICKER PUMP')
->example('1'),
ImportColumn::make('tube_sticker_pumpset')
// ->requiredMapping()
->requiredMapping()
->exampleHeader('Tube Sticker PumpSet')
->label('TUBE STICKER PUMPSET')
->example(''),
ImportColumn::make('warranty_card')
// ->requiredMapping()
->requiredMapping()
->exampleHeader('Warranty Card')
->label('WARRANTY CARD')
->example('1'),
ImportColumn::make('part_validation1')
// ->requiredMapping()
->requiredMapping()
->exampleHeader('Part Validation 1')
->label('PART VALIDATION 1')
->example('12345'),
ImportColumn::make('part_validation2')
// ->requiredMapping()
->requiredMapping()
->exampleHeader('Part Validation 2')
->label('PART VALIDATION 2')
->example('23456'),
ImportColumn::make('part_validation3')
// ->requiredMapping()
->requiredMapping()
->exampleHeader('Part Validation 3')
->label('PART VALIDATION 3')
->example('34567'),
ImportColumn::make('part_validation4')
// ->requiredMapping()
->requiredMapping()
->exampleHeader('Part Validation 4')
->label('PART VALIDATION 4')
->example('45678'),
ImportColumn::make('part_validation5')
// ->requiredMapping()
->requiredMapping()
->exampleHeader('Part Validation 5')
->label('PART VALIDATION 5')
->example('56789'),
ImportColumn::make('laser_part_validation1')
// ->requiredMapping()
->requiredMapping()
->exampleHeader('Laser Part Validation 1')
->label('LASER PART VALIDATION 1')
->example('67890'),
ImportColumn::make('laser_part_validation2')
// ->requiredMapping()
->requiredMapping()
->exampleHeader('Laser Part Validation 2')
->label('LASER PART VALIDATION 2')
->example('78901'),
ImportColumn::make('panel_box_code')
// ->requiredMapping()
->requiredMapping()
->exampleHeader('Panel Box Code')
->label('PANEL BOX CODE')
->example('123456'),
@@ -138,13 +138,13 @@ class StickerMasterImporter extends Importer
->example('0')
->rules(['required']),
ImportColumn::make('material_type')
// ->requiredMapping()
->requiredMapping()
->integer()
->exampleHeader('Material Type')
->label('MATERIAL TYPE')
->example(''),
ImportColumn::make('bundle_quantity')
// ->requiredMapping()
->requiredMapping()
->integer()
->exampleHeader('Bundle Quantity')
->label('BUNDLE QUANTITY')

View File

@@ -329,8 +329,12 @@ class EbReadingResource extends Resource
Select::make('Plant')
->label('Select Plant')
->nullable()
->options(function () {
return Plant::pluck('name', 'id');
// ->options(function () {
// return Plant::pluck('name', 'id');
// })
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
})
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {

View File

@@ -126,7 +126,6 @@ class GrMasterResource extends Resource
}
// else if (preg_match('/E CODE\s*:\s*(\S+)/i', $text, $matches)) {
// $item2 = $matches[1];
// dd($item2);
// }
@@ -189,7 +188,6 @@ class GrMasterResource extends Resource
}
else
{
Notification::make()
->title('Item Code not matched')
->body("Item Code: {$item->code} not matched with the uploaded pdf code $item1.")

View File

@@ -283,8 +283,12 @@ class GuardPatrolEntryResource extends Resource
Select::make('Plant')
->label('Select Plant')
->nullable()
->options(function () {
return Plant::pluck('name', 'id');
// ->options(function () {
// return Plant::pluck('name', 'id');
// })
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
})
->reactive(),
// ->afterStateUpdated(function ($state, callable $set, callable $get) {

View File

@@ -1025,8 +1025,12 @@ class InvoiceValidationResource extends Resource
Select::make('Plant')
->label('Select Plant')
->nullable()
->options(function () {
return Plant::pluck('name', 'id');
// ->options(function () {
// return Plant::pluck('name', 'id');
// })
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
})
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get): void {

View File

@@ -716,8 +716,12 @@ class LocatorInvoiceValidationResource extends Resource
Select::make('Plant')
->label('Select Plant')
->nullable()
->options(function () {
return Plant::pluck('name', 'id');
// ->options(function () {
// return Plant::pluck('name', 'id');
// })
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
})
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get): void {

View File

@@ -189,8 +189,12 @@ class LocatorResource extends Resource
Select::make('Plant')
->label('Select Plant')
->nullable()
->options(function () {
return Plant::pluck('name', 'id');
// ->options(function () {
// return Plant::pluck('name', 'id');
// })
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
})
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get): void {

View File

@@ -469,8 +469,12 @@ class MotorTestingMasterResource extends Resource
Select::make('Plant')
->label('Select Plant')
->nullable()
->options(function () {
return Plant::pluck('name', 'id');
// ->options(function () {
// return Plant::pluck('name', 'id');
// })
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
})
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {

View File

@@ -281,8 +281,12 @@ class PalletValidationResource extends Resource
Select::make('Plant')
->label('Select Plant')
->nullable()
->options(function () {
return Plant::pluck('name', 'id');
// ->options(function () {
// return Plant::pluck('name', 'id');
// })
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
})
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get): void {

View File

@@ -438,8 +438,12 @@ class ProductionLineStopResource extends Resource
Select::make('Plant')
->label('Select Plant')
->nullable()
->options(function () {
return Plant::pluck('name', 'id'); // Assuming 'name' is the column you want to display
// ->options(function () {
// return Plant::pluck('name', 'id'); // Assuming 'name' is the column you want to display
// })
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
})
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {

View File

@@ -588,8 +588,12 @@ class ProductionPlanResource extends Resource
Select::make('Plant')
->label('Select Plant')
->nullable()
->options(function () {
return Plant::pluck('name', 'id'); // Assuming 'name' is the column you want to display
// ->options(function () {
// return Plant::pluck('name', 'id'); // Assuming 'name' is the column you want to display
// })
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
})
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {

View File

@@ -1044,8 +1044,12 @@ class ProductionQuantityResource extends Resource
Select::make('Plant')
->label('Select Plant')
->nullable()
->options(function () {
return Plant::pluck('name', 'id'); // Assuming 'name' is the column you want to display
// ->options(function () {
// return Plant::pluck('name', 'id'); // Assuming 'name' is the column you want to display
// })
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
})
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {

View File

@@ -2318,8 +2318,12 @@ class QualityValidationResource extends Resource
Select::make('Plant')
->label('Select Plant')
->nullable()
->options(function () {
return Plant::pluck('name', 'id');
// ->options(function () {
// return Plant::pluck('name', 'id');
// })
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
})
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {

View File

@@ -466,8 +466,12 @@ class ReworkLocatorInvoiceValidationResource extends Resource
Select::make('Plant')
->label('Select Plant')
->nullable()
->options(function () {
return Plant::pluck('name', 'id');
// ->options(function () {
// return Plant::pluck('name', 'id');
// })
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
})
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get): void {

View File

@@ -1006,8 +1006,12 @@ class SerialValidationResource extends Resource
Select::make('Plant')
->label('Select Plant')
->nullable()
->options(function () {
return Plant::pluck('name', 'id');
// ->options(function () {
// return Plant::pluck('name', 'id');
// })
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
})
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get): void {

View File

@@ -168,8 +168,12 @@ class WeightValidationResource extends Resource
Select::make('Plant')
->label('Select Plant')
->nullable()
->options(function () {
return Plant::pluck('name', 'id');
// ->options(function () {
// return Plant::pluck('name', 'id');
// })
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
})
->reactive(),
// ->afterStateUpdated(function ($state, callable $set, callable $get) {