Updated getCharMaster function response against master record counts
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-27 01:13:10 +05:30
parent ab534b4c46
commit 9f6f9a6274

View File

@@ -2279,15 +2279,31 @@ 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 {
if ($charMasters->count() == 1) {
$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 ?? '',
];
} else { } else {
$output = $charMasters->map(function ($charMast) { $output = $charMasters->map(function ($charMast) {
$charMaster = [ $charMaster = [
'work_group_master' => optional($charMast->workGroupMaster)->name ?? '', 'work_group_master' => $charMast?->workGroupMaster->name ?? '', // optional($charMast->workGroupMaster)->name ?? '',
'name' => $charMast?->name ?? '', 'name' => $charMast?->name ?? '',
'characteristics_type' => $charMast?->characteristics_type ?? '', 'characteristics_type' => $charMast?->characteristics_type ?? '',
'inspection_type' => $charMast?->inspection_type ?? '', 'inspection_type' => $charMast?->inspection_type ?? '',
@@ -2299,21 +2315,7 @@ class CharacteristicsController extends Controller
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);
} }