ranjith-dev #418
@@ -2279,42 +2279,44 @@ class CharacteristicsController extends Controller
|
|||||||
|
|
||||||
$charMasters = ProductCharacteristicsMaster::with('workGroupMaster')->where('plant_id', $plantId)->where('item_id', $ItemId)->where('line_id', $lineId)->where('machine_id', $machineId)->get(); // ->select(['name', 'characteristics_type', 'inspection_type', 'lower', 'middle', 'upper', 'work_group_master_id'])
|
$charMasters = ProductCharacteristicsMaster::with('workGroupMaster')->where('plant_id', $plantId)->where('item_id', $ItemId)->where('line_id', $lineId)->where('machine_id', $machineId)->get(); // ->select(['name', 'characteristics_type', 'inspection_type', 'lower', 'middle', 'upper', 'work_group_master_id'])
|
||||||
|
|
||||||
if (! $charMasters) {
|
if ($charMasters->count() <= 0) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status_code' => 'ERROR',
|
'status_code' => 'ERROR',
|
||||||
'status_description' => "Characteristics not found in product master table for the plant : '$plant->name'!",
|
'status_description' => "Characteristics not found in product master table for the plant : '$plant->name'!",
|
||||||
], 404);
|
], 404);
|
||||||
} else {
|
} else {
|
||||||
$output = $charMasters->map(function ($charMast) {
|
if ($charMasters->count() == 1) {
|
||||||
$charMaster = [
|
$charMasters = ProductCharacteristicsMaster::with('workGroupMaster')->where('plant_id', $plantId)->where('item_id', $ItemId)->where('line_id', $lineId)->where('machine_id', $machineId)->first();
|
||||||
'work_group_master' => optional($charMast->workGroupMaster)->name ?? '',
|
|
||||||
'name' => $charMast?->name ?? '',
|
// $workGroup = WorkGroupMaster::find($charMasters->work_group_master_id);
|
||||||
'characteristics_type' => $charMast?->characteristics_type ?? '',
|
// $workGroupName = $workGroup?->name ?? '';
|
||||||
'inspection_type' => $charMast?->inspection_type ?? '',
|
|
||||||
'lower' => (string) $charMast?->lower ?? '',
|
$output = [
|
||||||
'middle' => (string) $charMast?->middle ?? '',
|
'work_group_master' => $charMasters?->workGroupMaster->name ?? '', // $workGroupName ?? '',
|
||||||
'upper' => (string) $charMast?->upper ?? '',
|
'name' => $charMasters?->name ?? '',
|
||||||
|
'characteristics_type' => $charMasters?->characteristics_type ?? '',
|
||||||
|
'inspection_type' => $charMasters?->inspection_type ?? '',
|
||||||
|
'lower' => (string) $charMasters?->lower ?? '',
|
||||||
|
'middle' => (string) $charMasters?->middle ?? '',
|
||||||
|
'upper' => (string) $charMasters?->upper ?? '',
|
||||||
];
|
];
|
||||||
|
} else {
|
||||||
|
$output = $charMasters->map(function ($charMast) {
|
||||||
|
$charMaster = [
|
||||||
|
'work_group_master' => $charMast?->workGroupMaster->name ?? '', // optional($charMast->workGroupMaster)->name ?? '',
|
||||||
|
'name' => $charMast?->name ?? '',
|
||||||
|
'characteristics_type' => $charMast?->characteristics_type ?? '',
|
||||||
|
'inspection_type' => $charMast?->inspection_type ?? '',
|
||||||
|
'lower' => (string) $charMast?->lower ?? '',
|
||||||
|
'middle' => (string) $charMast?->middle ?? '',
|
||||||
|
'upper' => (string) $charMast?->upper ?? '',
|
||||||
|
];
|
||||||
|
|
||||||
return $charMaster;
|
return $charMaster;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// $charMasters = ProductCharacteristicsMaster::with('workGroupMaster')->where('plant_id', $plantId)->where('item_id', $ItemId)->where('line_id', $lineId)->where('machine_id', $machineId)->first();
|
|
||||||
|
|
||||||
// // $workGroup = WorkGroupMaster::find($charMasters->work_group_master_id);
|
|
||||||
// // $workGroupName = $workGroup?->name ?? '';
|
|
||||||
|
|
||||||
// $output = [
|
|
||||||
// 'work_group_master' => $charMasters?->workGroupMaster->name ?? '', // $workGroupName ?? '',
|
|
||||||
// 'name' => $charMasters?->name ?? '',
|
|
||||||
// 'characteristics_type' => $charMasters?->characteristics_type ?? '',
|
|
||||||
// 'inspection_type' => $charMasters?->inspection_type ?? '',
|
|
||||||
// 'lower' => (string) $charMasters?->lower ?? '',
|
|
||||||
// 'middle' => (string) $charMasters?->middle ?? '',
|
|
||||||
// 'upper' => (string) $charMasters?->upper ?? '',
|
|
||||||
// ];
|
|
||||||
|
|
||||||
return response()->json($output, 200);
|
return response()->json($output, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user