where('variable', 'CTRL_AUTO_SELECT') ->first(); if (! $ctrlFormula) { $this->command->warn('CTRL_AUTO_SELECT 수식을 찾을 수 없습니다.'); return; } $mappings = [ // 제어기 자동 선택 - CONTROLLER_TYPE 기반 [ 'formula_id' => $ctrlFormula->id, 'source_variable' => 'CONTROLLER_TYPE', 'source_value' => '매립형', 'result_value' => json_encode([ 'value' => '매립형 제어기', 'item_code' => 'PT-CTRL-EMB', 'quantity' => 1, 'note' => '매립형 설치', ], JSON_UNESCAPED_UNICODE), 'result_type' => 'fixed', 'sort_order' => 1, ], [ 'formula_id' => $ctrlFormula->id, 'source_variable' => 'CONTROLLER_TYPE', 'source_value' => '노출형', 'result_value' => json_encode([ 'value' => '노출형 제어기', 'item_code' => 'PT-CTRL-EXP', 'quantity' => 1, 'note' => '노출형 설치', ], JSON_UNESCAPED_UNICODE), 'result_type' => 'fixed', 'sort_order' => 2, ], [ 'formula_id' => $ctrlFormula->id, 'source_variable' => 'CONTROLLER_TYPE', 'source_value' => '일체형', 'result_value' => json_encode([ 'value' => '일체형 제어기', 'item_code' => 'PT-CTRL-INT', 'quantity' => 1, 'note' => '모터 일체형', ], JSON_UNESCAPED_UNICODE), 'result_type' => 'fixed', 'sort_order' => 3, ], ]; foreach ($mappings as $mapping) { DB::table('quote_formula_mappings')->updateOrInsert( [ 'formula_id' => $mapping['formula_id'], 'source_variable' => $mapping['source_variable'], 'source_value' => $mapping['source_value'], ], array_merge($mapping, [ 'created_at' => now(), 'updated_at' => now(), ]) ); } $this->command->info('QuoteFormulaMappingSeeder: 3개 매핑 생성 완료'); } }