'array', 'options' => 'array', 'is_active' => 'boolean', 'rail_width' => 'decimal:2', 'box_width' => 'decimal:2', 'box_height' => 'decimal:2', 'front_bottom' => 'decimal:2', ]; protected $hidden = ['deleted_at']; // ────────────────────────────────────────────────────────────── // 관계 // ────────────────────────────────────────────────────────────── public function files(): HasMany { return $this->hasMany(File::class, 'document_id') ->where('document_type', 'bending_item'); } // ────────────────────────────────────────────────────────────── // options 헬퍼 // ────────────────────────────────────────────────────────────── public function getOption(string $key, mixed $default = null): mixed { return data_get($this->options, $key, $default); } public function setOption(string $key, mixed $value): self { $options = $this->options ?? []; data_set($options, $key, $value); $this->options = $options; return $this; } // ────────────────────────────────────────────────────────────── // 계산 accessor // ────────────────────────────────────────────────────────────── public function getWidthSumAttribute(): ?float { $data = $this->bending_data ?? []; if (empty($data)) { return null; } $last = end($data); return isset($last['sum']) ? (float) $last['sum'] : null; } public function getBendCountAttribute(): int { $data = $this->bending_data ?? []; return count(array_filter($data, fn ($d) => ($d['rate'] ?? '') !== '')); } // ────────────────────────────────────────────────────────────── // LOT 코드 테이블 // ────────────────────────────────────────────────────────────── public const PROD_CODES = [ 'R' => '가이드레일(벽면형)', 'S' => '가이드레일(측면형)', 'C' => '케이스', 'B' => '하단마감재(스크린)', 'T' => '하단마감재(철재)', 'L' => 'L-Bar', 'G' => '연기차단재', ]; public const SPEC_CODES = [ 'R' => ['M' => '본체', 'T' => '본체(철재)', 'C' => 'C형', 'D' => 'D형', 'S' => 'SUS 마감재'], 'S' => ['M' => '본체디딤', 'T' => '본체(철재)', 'C' => 'C형', 'D' => 'D형', 'S' => 'SUS 마감재①', 'U' => 'SUS 마감재②'], 'C' => ['F' => '전면부', 'P' => '점검구', 'L' => '린텔부', 'B' => '후면코너부'], 'B' => ['S' => 'SUS', 'E' => 'EGI'], 'T' => ['S' => 'SUS', 'E' => 'EGI'], 'L' => ['A' => '스크린용'], 'G' => ['I' => '화이바원단'], ]; }