Updated item code filter option against plant from stickerMaster
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 10s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 10s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 16s
Laravel Pint / pint (pull_request) Successful in 2m50s
Laravel Larastan / larastan (pull_request) Failing after 3m46s

This commit is contained in:
dhanabalan
2026-01-13 15:39:42 +05:30
parent 26b4cd9363
commit bec3e9f8bd

View File

@@ -620,7 +620,17 @@ class StickerMasterResource extends Resource
->options(function (callable $get) {
$plantId = $get('Plant');
return $plantId ? Item::where('plant_id', $plantId)->pluck('code', 'id') : [];
if (! $plantId) {
return [];
}
return Item::whereHas('stickerMasters', function ($query) use ($plantId) {
if ($plantId) {
$query->where('plant_id', $plantId);
}
})->pluck('code', 'id');
// return $plantId ? Item::where('plant_id', $plantId)->pluck('code', 'id') : [];
})
->searchable()
->reactive(),