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(),
|
->reactive(),
|
||||||
Forms\Components\Select::make('motor_testing_master_id')
|
Forms\Components\Select::make('motor_testing_master_id')
|
||||||
->label('Item Code')
|
->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) {
|
->options(function (callable $get) {
|
||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
if (!$plantId) {
|
if (!$plantId) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
return MotorTestingMaster::query()
|
||||||
// return MotorTestingMaster::with('item')
|
->join('items', 'motor_testing_masters.item_id', '=', 'items.id')
|
||||||
// ->whereHas('motorTestingMasters', function ($query) use ($plantId) {
|
->where('motor_testing_masters.plant_id', $plantId)
|
||||||
// $query->where('plant_id', $plantId);
|
->select('motor_testing_masters.id', 'items.code')
|
||||||
// })->pluck('item.code', 'id')->toArray();
|
->pluck('items.code', 'motor_testing_masters.id')
|
||||||
// // ->get();
|
->toArray();
|
||||||
|
|
||||||
return Item::where('plant_id', $plantId)->whereHas('motorTestingMasters')->pluck('code', 'id')->toArray();
|
|
||||||
// return Item::whereHas('motorTestingMasters')->pluck('code', 'id')->toArray();
|
|
||||||
})
|
})
|
||||||
|
// ->getOptionLabelUsing(fn ($value) =>
|
||||||
|
// MotorTestingMaster::with('item')->find($value)?->item?->code
|
||||||
|
// )
|
||||||
->required()
|
->required()
|
||||||
->searchable()
|
->searchable()
|
||||||
->reactive(),
|
->reactive(),
|
||||||
|
|||||||
Reference in New Issue
Block a user