issue solved in edit screen of item code in testing panel readings
This commit is contained in:
@@ -119,22 +119,34 @@ class TestingPanelReadingResource extends Resource
|
||||
->reactive(),
|
||||
Forms\Components\Select::make('motor_testing_master_id')
|
||||
->label('Item Code')
|
||||
->relationship('motorTestingMaster', 'item.code')
|
||||
//->relationship('motorTestingMaster', 'item.code')
|
||||
// ->options(function (callable $get) {
|
||||
// $plantId = $get('plant_id');
|
||||
// if (!$plantId) {
|
||||
// return [];
|
||||
// }
|
||||
// return MotorTestingMaster::with('item')
|
||||
// ->where('plant_id', $plantId)
|
||||
// ->get()
|
||||
// //->filter(fn ($mtm) => $mtm->item)
|
||||
// ->pluck('item.code', 'id')
|
||||
// ->toArray();
|
||||
// })
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (!$plantId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// return MotorTestingMaster::with('item')
|
||||
// ->whereHas('motorTestingMasters', function ($query) use ($plantId) {
|
||||
// $query->where('plant_id', $plantId);
|
||||
// })->pluck('item.code', 'id')->toArray();
|
||||
// // ->get();
|
||||
|
||||
return Item::where('plant_id', $plantId)->whereHas('motorTestingMasters')->pluck('code', 'id')->toArray();
|
||||
// return Item::whereHas('motorTestingMasters')->pluck('code', 'id')->toArray();
|
||||
return MotorTestingMaster::query()
|
||||
->join('items', 'motor_testing_masters.item_id', '=', 'items.id')
|
||||
->where('motor_testing_masters.plant_id', $plantId)
|
||||
->select('motor_testing_masters.id', 'items.code')
|
||||
->pluck('items.code', 'motor_testing_masters.id')
|
||||
->toArray();
|
||||
})
|
||||
// ->getOptionLabelUsing(fn ($value) =>
|
||||
// MotorTestingMaster::with('item')->find($value)?->item?->code
|
||||
// )
|
||||
->required()
|
||||
->searchable()
|
||||
->reactive(),
|
||||
|
||||
Reference in New Issue
Block a user