Updated plant load logic for filter report on resource file
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
This commit is contained in:
@@ -1198,17 +1198,23 @@ class InvoiceValidationResource extends Resource
|
||||
->inlineLabel(false)
|
||||
->inline(),
|
||||
Select::make('Plant')
|
||||
->label('Select Plant')
|
||||
->label('Search by Plant Name')
|
||||
->nullable()
|
||||
// ->options(function () {
|
||||
// return Plant::pluck('name', 'id');
|
||||
// })
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||
} else {
|
||||
return Plant::whereHas('invoiceValidations', function ($query) {
|
||||
$query->whereNotNull('id');
|
||||
})->orderBy('code')->pluck('name', 'id');
|
||||
}
|
||||
|
||||
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||
$set('sticker_master_id', null);
|
||||
$set('operator_id', null);
|
||||
@@ -1222,6 +1228,8 @@ class InvoiceValidationResource extends Resource
|
||||
Select::make('sticker_master_id')
|
||||
->label('Search by Item Code')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$pId = $get('Plant');
|
||||
|
||||
@@ -1234,9 +1242,7 @@ class InvoiceValidationResource extends Resource
|
||||
}
|
||||
$query->whereHas('invoiceValidations');
|
||||
})->pluck('code', 'id');
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
}),
|
||||
Select::make('scanned_status')
|
||||
->label('Scanned Status')
|
||||
->nullable()
|
||||
@@ -1356,7 +1362,7 @@ class InvoiceValidationResource extends Resource
|
||||
$indicators = [];
|
||||
|
||||
if (! empty($data['Plant'])) {
|
||||
$indicators[] = 'Plant: '.Plant::where('id', $data['Plant'])->value('name');
|
||||
$indicators[] = 'Plant Name: '.Plant::where('id', $data['Plant'])->value('name');
|
||||
} else {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user