ranjith-dev #418
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Filament\Exports;
|
namespace App\Filament\Exports;
|
||||||
|
|
||||||
use App\Models\CharacteristicValue;
|
use App\Models\CharacteristicValue;
|
||||||
|
use App\Models\ProductCharacteristicsMaster;
|
||||||
use Filament\Actions\Exports\ExportColumn;
|
use Filament\Actions\Exports\ExportColumn;
|
||||||
use Filament\Actions\Exports\Exporter;
|
use Filament\Actions\Exports\Exporter;
|
||||||
use Filament\Actions\Exports\Models\Export;
|
use Filament\Actions\Exports\Models\Export;
|
||||||
@@ -28,6 +29,8 @@ class CharacteristicValueExporter extends Exporter
|
|||||||
->label('LINE NAME'),
|
->label('LINE NAME'),
|
||||||
ExportColumn::make('item.code')
|
ExportColumn::make('item.code')
|
||||||
->label('ITEM CODE'),
|
->label('ITEM CODE'),
|
||||||
|
ExportColumn::make('item.description')
|
||||||
|
->label('DESCRIPTION'),
|
||||||
ExportColumn::make('machine.work_center')
|
ExportColumn::make('machine.work_center')
|
||||||
->label('WORK CENTER'),
|
->label('WORK CENTER'),
|
||||||
ExportColumn::make('process_order')
|
ExportColumn::make('process_order')
|
||||||
@@ -36,6 +39,18 @@ class CharacteristicValueExporter extends Exporter
|
|||||||
->label('COIL NUMBER'),
|
->label('COIL NUMBER'),
|
||||||
ExportColumn::make('status')
|
ExportColumn::make('status')
|
||||||
->label('STATUS'),
|
->label('STATUS'),
|
||||||
|
ExportColumn::make('spec_value')
|
||||||
|
->label('Spec. Value')
|
||||||
|
->formatStateUsing(function ($record) {
|
||||||
|
|
||||||
|
$specVal = ProductCharacteristicsMaster::where('plant_id', $record->plant_id)
|
||||||
|
->where('item_id', $record->item_id)
|
||||||
|
->where('line_id', $record->line_id)
|
||||||
|
->where('machine_id', $record->machine_id)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
return $specVal?->lower . ' - ' . $specVal?->upper;
|
||||||
|
}),
|
||||||
ExportColumn::make('observed_value')
|
ExportColumn::make('observed_value')
|
||||||
->label('OBSERVED VALUE'),
|
->label('OBSERVED VALUE'),
|
||||||
ExportColumn::make('created_at')
|
ExportColumn::make('created_at')
|
||||||
|
|||||||
@@ -24,13 +24,13 @@ class ProcessOrderImporter extends Importer
|
|||||||
ImportColumn::make('plant')
|
ImportColumn::make('plant')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->exampleHeader('PLANT CODE')
|
->exampleHeader('PLANT CODE')
|
||||||
->example('1000')
|
->example('1200')
|
||||||
->label('PLANT CODE')
|
->label('PLANT CODE')
|
||||||
->relationship(resolveUsing: 'code')
|
->relationship(resolveUsing: 'code')
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
ImportColumn::make('line')
|
ImportColumn::make('line')
|
||||||
->exampleHeader('LINE NAME')
|
->exampleHeader('LINE NAME')
|
||||||
->example(' Polywrapped line')
|
->example(' Poly Wrapped Wire SFG')
|
||||||
->label('LINE NAME')
|
->label('LINE NAME')
|
||||||
->relationship(resolveUsing: 'name'),
|
->relationship(resolveUsing: 'name'),
|
||||||
ImportColumn::make('item')
|
ImportColumn::make('item')
|
||||||
@@ -43,54 +43,54 @@ class ProcessOrderImporter extends Importer
|
|||||||
ImportColumn::make('process_order')
|
ImportColumn::make('process_order')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->exampleHeader('PROCESS ORDER')
|
->exampleHeader('PROCESS ORDER')
|
||||||
->example('202500123456')
|
->example('2025002123456')
|
||||||
->label('PROCESS ORDER')
|
->label('PROCESS ORDER')
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
ImportColumn::make('coil_number')
|
|
||||||
->exampleHeader('COIL NUMBER')
|
|
||||||
->example('01')
|
|
||||||
->label('COIL NUMBER'),
|
|
||||||
ImportColumn::make('order_quantity')
|
ImportColumn::make('order_quantity')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->exampleHeader('ORDER QUANTITY')
|
->exampleHeader('ORDER QUANTITY')
|
||||||
->example('100')
|
->example('1000')
|
||||||
->label('ORDER QUANTITY')
|
->label('ORDER QUANTITY')
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
|
ImportColumn::make('coil_number')
|
||||||
|
->exampleHeader('COIL NUMBER')
|
||||||
|
// ->example('01')
|
||||||
|
->label('COIL NUMBER'),
|
||||||
ImportColumn::make('received_quantity')
|
ImportColumn::make('received_quantity')
|
||||||
->exampleHeader('RECEIVED QUANTITY')
|
->exampleHeader('RECEIVED QUANTITY')
|
||||||
->example('01')
|
// ->example('01')
|
||||||
->label('RECEIVED QUANTITY'),
|
->label('RECEIVED QUANTITY'),
|
||||||
ImportColumn::make('sfg_number')
|
ImportColumn::make('sfg_number')
|
||||||
->exampleHeader('SFG NUMBER')
|
->exampleHeader('SFG NUMBER')
|
||||||
->example('200000220613-72')
|
// ->example('200000220613-72')
|
||||||
->label('SFG NUMBER'),
|
->label('SFG NUMBER'),
|
||||||
ImportColumn::make('machine_name')
|
ImportColumn::make('machine_name')
|
||||||
->exampleHeader('MACHINE NAME')
|
->exampleHeader('MACHINE NAME')
|
||||||
->example('WMIWRM13 - 2-L2')
|
// ->example('WMIWRM13 - 2-L2')
|
||||||
->label('MACHINE NAME'),
|
->label('MACHINE NAME'),
|
||||||
ImportColumn::make('scrap_quantity')
|
ImportColumn::make('scrap_quantity')
|
||||||
->exampleHeader('SCRAP QUANTITY')
|
->exampleHeader('SCRAP QUANTITY')
|
||||||
->example('0')
|
// ->example('0')
|
||||||
->label('SCRAP QUANTITY'),
|
->label('SCRAP QUANTITY'),
|
||||||
ImportColumn::make('rework_status')
|
ImportColumn::make('rework_status')
|
||||||
->exampleHeader('REWORK STATUS')
|
->exampleHeader('REWORK STATUS')
|
||||||
->example('0')
|
// ->example('0')
|
||||||
->label('REWORK STATUS'),
|
->label('REWORK STATUS'),
|
||||||
ImportColumn::make('created_at')
|
ImportColumn::make('created_at')
|
||||||
->exampleHeader('CREATED AT')
|
->exampleHeader('CREATED AT')
|
||||||
->example('2026-02-20 13:00:00')
|
// ->example('2026-02-20 13:00:00')
|
||||||
->label('CREATED AT'),
|
->label('CREATED AT'),
|
||||||
ImportColumn::make('updated_at')
|
ImportColumn::make('updated_at')
|
||||||
->exampleHeader('UPDATED AT')
|
->exampleHeader('UPDATED AT')
|
||||||
->example('2026-02-20 13:00:00')
|
// ->example('2026-02-20 13:00:00')
|
||||||
->label('UPDATED AT'),
|
->label('UPDATED AT'),
|
||||||
ImportColumn::make('created_by')
|
ImportColumn::make('created_by')
|
||||||
->exampleHeader('CREATED BY')
|
->exampleHeader('CREATED BY')
|
||||||
->example('RAW01234')
|
// ->example('RAW01234')
|
||||||
->label('CREATED BY'),
|
->label('CREATED BY'),
|
||||||
ImportColumn::make('updated_by')
|
ImportColumn::make('updated_by')
|
||||||
->exampleHeader('UPDATED BY')
|
->exampleHeader('UPDATED BY')
|
||||||
->example('RAW01234')
|
// ->example('RAW01234')
|
||||||
->label('UPDATED BY'),
|
->label('UPDATED BY'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -98,12 +98,13 @@ class ProcessOrderImporter extends Importer
|
|||||||
public function resolveRecord(): ?ProcessOrder
|
public function resolveRecord(): ?ProcessOrder
|
||||||
{
|
{
|
||||||
$warnMsg = [];
|
$warnMsg = [];
|
||||||
$plantCod = $this->data['plant'];
|
|
||||||
$plant = null;
|
$plant = null;
|
||||||
|
$plantCod = trim($this->data['plant']) ?? '';
|
||||||
$plantId = null;
|
$plantId = null;
|
||||||
|
$item = null;
|
||||||
|
$iCode = trim($this->data['item']) ?? '';
|
||||||
$itemId = null;
|
$itemId = null;
|
||||||
$iCode = trim($this->data['item']);
|
$lineNam = trim($this->data['line']) ?? '';
|
||||||
$lineName = trim($this->data['line']);
|
|
||||||
$processOrder = trim($this->data['process_order'] ?? '');
|
$processOrder = trim($this->data['process_order'] ?? '');
|
||||||
$coilNo = trim($this->data['coil_number'] ?? '');
|
$coilNo = trim($this->data['coil_number'] ?? '');
|
||||||
$sfgNo = trim($this->data['sfg_number'] ?? '');
|
$sfgNo = trim($this->data['sfg_number'] ?? '');
|
||||||
@@ -120,18 +121,27 @@ class ProcessOrderImporter extends Importer
|
|||||||
// $operatorName = $user->name;
|
// $operatorName = $user->name;
|
||||||
|
|
||||||
if ($plantCod == null || $plantCod == '') {
|
if ($plantCod == null || $plantCod == '') {
|
||||||
$warnMsg[] = 'Plant code cannot be empty';
|
$warnMsg[] = "Plant code can't be empty!";
|
||||||
|
} elseif (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
||||||
|
$warnMsg[] = 'Invalid plant code found';
|
||||||
}
|
}
|
||||||
if ($iCode == null || $iCode == '') {
|
if ($iCode == null || $iCode == '') {
|
||||||
$warnMsg[] = 'Item code cannot be empty';
|
$warnMsg[] = "Item code can't be empty!";
|
||||||
|
} elseif (Str::length($iCode) < 6 || ! ctype_alnum($iCode)) {
|
||||||
|
$warnMsg[] = 'Invalid item code found';
|
||||||
}
|
}
|
||||||
if ($processOrder == null || $processOrder == '') {
|
if ($processOrder == null || $processOrder == '') {
|
||||||
$warnMsg[] = 'Process order cannot be empty';
|
$warnMsg[] = "Process order can't be empty!";
|
||||||
|
}
|
||||||
|
if ($lineNam == null || $lineNam == '') {
|
||||||
|
$warnMsg[] = "Line name can't be empty!";
|
||||||
}
|
}
|
||||||
if ($orderQuan == null || $orderQuan == '') {
|
if ($orderQuan == null || $orderQuan == '') {
|
||||||
$warnMsg[] = 'Order quantity cannot be empty';
|
$warnMsg[] = "Order quantity can't be empty!";
|
||||||
} elseif ($orderQuan == 0 || $orderQuan == '0') {
|
} elseif ($orderQuan == 0 || $orderQuan == '0') {
|
||||||
$warnMsg[] = 'Order quantity cannot be zero';
|
$warnMsg[] = "Order quantity can't be zero!";
|
||||||
|
} elseif (Str::length($orderQuan) >= 1 && ! is_numeric($orderQuan)) {
|
||||||
|
$warnMsg[] = 'Invalid order quantity found!';
|
||||||
}
|
}
|
||||||
if ($coilNo == null || $coilNo == '') {
|
if ($coilNo == null || $coilNo == '') {
|
||||||
$coilNo = '0';
|
$coilNo = '0';
|
||||||
@@ -150,37 +160,46 @@ class ProcessOrderImporter extends Importer
|
|||||||
$warnMsg[] = 'Invalid rework status found';
|
$warnMsg[] = 'Invalid rework status found';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
if (! empty($warnMsg)) {
|
||||||
$warnMsg[] = 'Invalid plant code found';
|
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||||
} else {
|
|
||||||
$plant = Plant::where('code', $plantCod)->first();
|
|
||||||
if (! $plant) {
|
|
||||||
$warnMsg[] = 'Plant not found';
|
|
||||||
} else {
|
|
||||||
$plantId = $plant->id;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Str::length($iCode) < 6 || ! ctype_alnum($iCode)) {
|
$plant = Plant::where('code', $plantCod)->first();
|
||||||
$warnMsg[] = 'Invalid item code found';
|
if (! $plant) {
|
||||||
|
$warnMsg[] = 'Plant not found!';
|
||||||
} else {
|
} else {
|
||||||
$itemCode = Item::where('code', $iCode)->first();
|
$plantId = $plant->id;
|
||||||
if (! $itemCode) {
|
}
|
||||||
$warnMsg[] = 'Item code not found';
|
|
||||||
} else {
|
$itemCode = Item::where('code', $iCode)->first();
|
||||||
if ($plantId) {
|
if (! $itemCode) {
|
||||||
$itemCode = Item::where('code', $iCode)->where('plant_id', $plantId)->first();
|
$warnMsg[] = 'Item code not found!';
|
||||||
if (! $itemCode) {
|
} else {
|
||||||
$warnMsg[] = 'Item code not found for the given plant';
|
if ($plantId) {
|
||||||
} else {
|
$itemCode = Item::where('code', $iCode)->where('plant_id', $plantId)->first();
|
||||||
$itemId = $itemCode->id;
|
if (! $itemCode) {
|
||||||
}
|
$warnMsg[] = 'Item code not found for the given plant!';
|
||||||
|
} else {
|
||||||
|
$itemId = $itemCode->id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($plant && $itemCode && $processOrder != '') {
|
$lineExists = Line::where('name', $lineNam)->first();
|
||||||
|
if (! $lineExists) {
|
||||||
|
$warnMsg[] = 'Line name not found!';
|
||||||
|
} else {
|
||||||
|
if ($plantId) {
|
||||||
|
$lineAgainstPlant = Line::where('name', $lineNam)->where('plant_id', $plantId)->first();
|
||||||
|
if (! $lineAgainstPlant) {
|
||||||
|
$warnMsg[] = 'Line name not found for the given plant!';
|
||||||
|
} else {
|
||||||
|
$lineId = $lineAgainstPlant->id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($plantId && $itemCode && $lineId && $processOrder != '') {
|
||||||
$existingOrder = ProcessOrder::where('plant_id', $plantId)
|
$existingOrder = ProcessOrder::where('plant_id', $plantId)
|
||||||
->where('process_order', $processOrder)
|
->where('process_order', $processOrder)
|
||||||
->first();
|
->first();
|
||||||
@@ -190,27 +209,9 @@ class ProcessOrderImporter extends Importer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($lineName != null && $lineName != '') {
|
|
||||||
$lineExists = Line::where('name', $lineName)->first();
|
|
||||||
if (! $lineExists) {
|
|
||||||
$warnMsg[] = 'Line name not found';
|
|
||||||
} else {
|
|
||||||
if ($plantId) {
|
|
||||||
$lineAgainstPlant = Line::where('name', $lineName)->where('plant_id', $plantId)->first();
|
|
||||||
if (! $lineAgainstPlant) {
|
|
||||||
$warnMsg[] = 'Line name not found for the given plant';
|
|
||||||
} else {
|
|
||||||
$lineId = $lineAgainstPlant->id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$lineId = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// $user = User::where('name', $this->data['created_by'])->first();
|
// $user = User::where('name', $this->data['created_by'])->first();
|
||||||
// if (! $user) {
|
// if (! $user) {
|
||||||
// $warnMsg[] = 'User not found';
|
// $warnMsg[] = 'User not found!';
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (! $createdBy) {
|
if (! $createdBy) {
|
||||||
@@ -224,7 +225,7 @@ class ProcessOrderImporter extends Importer
|
|||||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($lineName != null && $lineName != '') {
|
if ($coilNo != null && $coilNo != '' && $scrapQuan && $reworkStatus && $recQuan && $createdAt && $createdBy && $updatedAt && $updatedBy && Filament::auth()->user()->hasRole('Super Admin')) {
|
||||||
$existingCoil = ProcessOrder::where('plant_id', $plantId)
|
$existingCoil = ProcessOrder::where('plant_id', $plantId)
|
||||||
->where('process_order', $processOrder)
|
->where('process_order', $processOrder)
|
||||||
->where('line_id', $lineId)
|
->where('line_id', $lineId)
|
||||||
@@ -267,11 +268,11 @@ class ProcessOrderImporter extends Importer
|
|||||||
'updated_at' => $updatedAt,
|
'updated_at' => $updatedAt,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
} elseif ($lineName == null || $lineName == '') {
|
$coilNo = '0';
|
||||||
$existing = ProcessOrder::where('plant_id', $plantId)
|
$existing = ProcessOrder::where('plant_id', $plantId)
|
||||||
->where('process_order', $processOrder)
|
->where('process_order', $processOrder)
|
||||||
->where('coil_number', $coilNo)
|
// ->where('coil_number', $coilNo)
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if (! $existing && ($coilNo == '0' || $coilNo == 0)) {
|
if (! $existing && ($coilNo == '0' || $coilNo == 0)) {
|
||||||
@@ -308,23 +309,25 @@ class ProcessOrderImporter extends Importer
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
} else {// $coilNo = '0'
|
} else {// $coilNo = '0'
|
||||||
if ($existing->rework_status == 1 && $reworkStatus == 0) {
|
if ($existing->process_order == $processOrder) {
|
||||||
|
throw new RowImportFailedException('Process order already exist for the given plant!');
|
||||||
|
} elseif ($existing->rework_status == 1 && $reworkStatus == 0) {
|
||||||
throw new RowImportFailedException('Rework coil number already exist for the given Plant and Process Order!');
|
throw new RowImportFailedException('Rework coil number already exist for the given Plant and Process Order!');
|
||||||
|
} else {
|
||||||
|
ProcessOrder::where('plant_id', $plantId)
|
||||||
|
->where('process_order', $processOrder)
|
||||||
|
->where('coil_number', $coilNo)
|
||||||
|
->update([
|
||||||
|
// 'order_quantity' => $orderQty,
|
||||||
|
'received_quantity' => $recQuan,
|
||||||
|
'scrap_quantity' => $scrapQuan,
|
||||||
|
// 'sfg_number' => $sfgNo,
|
||||||
|
// 'machine_name' => $machineId,
|
||||||
|
'rework_status' => $reworkStatus,
|
||||||
|
'updated_by' => $updatedBy,
|
||||||
|
// 'updated_at' => $updatedAt,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessOrder::where('plant_id', $plantId)
|
|
||||||
->where('process_order', $processOrder)
|
|
||||||
->where('coil_number', $coilNo)
|
|
||||||
->update([
|
|
||||||
// 'order_quantity' => $orderQty,
|
|
||||||
'received_quantity' => $recQuan,
|
|
||||||
'scrap_quantity' => $scrapQuan,
|
|
||||||
// 'sfg_number' => $sfgNo,
|
|
||||||
// 'machine_name' => $machineId,
|
|
||||||
'rework_status' => $reworkStatus,
|
|
||||||
'updated_by' => $updatedBy,
|
|
||||||
// 'updated_at' => $updatedAt,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ use Filament\Facades\Filament;
|
|||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
use Filament\Forms\Components\Actions\Action;
|
use Filament\Forms\Components\Actions\Action;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
|
use Filament\Forms\Get;
|
||||||
use Filament\Notifications\Notification;
|
use Filament\Notifications\Notification;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
@@ -45,6 +46,7 @@ class GrMasterResource extends Resource
|
|||||||
->reactive()
|
->reactive()
|
||||||
->searchable()
|
->searchable()
|
||||||
->relationship('plant', 'name')
|
->relationship('plant', 'name')
|
||||||
|
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
@@ -56,6 +58,7 @@ class GrMasterResource extends Resource
|
|||||||
// ->relationship('item', 'id')
|
// ->relationship('item', 'id')
|
||||||
->reactive()
|
->reactive()
|
||||||
->searchable()
|
->searchable()
|
||||||
|
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
if (empty($plantId)) {
|
if (empty($plantId)) {
|
||||||
|
|||||||
@@ -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