feat: [quote] 수식 시더 품목/매핑 데이터 추가
- QuoteFormulaSeeder: CONTROLLER_TYPE input 수식 추가 - QuoteFormulaItemSeeder: 14개 품목 마스터 (GR, CASE, MOTOR, CTRL, EDGE, INSP) - QuoteFormulaMappingSeeder: CTRL_AUTO_SELECT 매핑 3건 (매립형/노출형/일체형)
This commit is contained in:
86
database/seeders/QuoteFormulaMappingSeeder.php
Normal file
86
database/seeders/QuoteFormulaMappingSeeder.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class QuoteFormulaMappingSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* 견적수식 매핑 시드 데이터
|
||||
* mapping 타입 수식(CTRL_AUTO_SELECT)의 조건별 결과값
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// CTRL_AUTO_SELECT 수식 ID 조회
|
||||
$ctrlFormula = DB::table('quote_formulas')
|
||||
->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개 매핑 생성 완료');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user