Added hasMany relation on model files and Updated report filter functionality (and plant order by code) on resource file
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s

This commit is contained in:
dhanabalan
2026-02-26 22:11:36 +05:30
parent 6ff1718ca2
commit 17fcaf8b20
3 changed files with 18 additions and 5 deletions

View File

@@ -432,7 +432,15 @@ class ProductCharacteristicsMasterResource extends Resource
->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('productCharacteristicsMasters', 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();
})
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('Item', null);
@@ -463,6 +471,7 @@ class ProductCharacteristicsMasterResource extends Resource
->label('Search by Item Code')
->nullable()
->searchable()
->reactive()
->options(function (callable $get) {
$plantId = $get('Plant');
@@ -475,8 +484,7 @@ class ProductCharacteristicsMasterResource extends Resource
$query->where('plant_id', $plantId);
}
})->pluck('code', 'id');
})
->reactive(),
}),
// ->afterStateUpdated(function ($state, callable $set, callable $get) {
// $set('process_order', null);
// }),
@@ -517,7 +525,7 @@ class ProductCharacteristicsMasterResource extends Resource
}
return Machine::whereHas('productCharacteristicsMasters', function ($query) use ($plantId, $lineId, $workGroupMasterId) {
if ($plantId && $lineId) {
if ($plantId && $lineId && $workGroupMasterId) {
$query->where('plant_id', $plantId)->where('line_id', $lineId)->where('work_group_master_id', $workGroupMasterId);
}
})->pluck('work_center', 'id');