- bending_items 전용 테이블 생성 (items.options → 정규 컬럼 승격) - bending_models 전용 테이블 생성 (가이드레일/케이스/하단마감재 통합) - bending_data JSON 통합 (별도 테이블 → bending_items.bending_data 컬럼) - bending_item_mappings 테이블 DROP (bending_items.code에 흡수) - BendingItemService/BendingCodeService → BendingItem 모델 전환 - GuiderailModelService component 이미지 자동 복사 - ItemsFileController bending_items/bending_models 폴백 지원 - Swagger 스키마 업데이트
69 lines
2.0 KiB
PHP
69 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Models\Commons\File;
|
|
use App\Traits\Auditable;
|
|
use App\Traits\BelongsToTenant;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class BendingModel extends Model
|
|
{
|
|
use Auditable, BelongsToTenant, SoftDeletes;
|
|
|
|
protected $table = 'bending_models';
|
|
|
|
protected $fillable = [
|
|
'tenant_id', 'model_type', 'code', 'name', 'legacy_code', 'legacy_num',
|
|
'model_name', 'model_UA', 'item_sep', 'finishing_type', 'author', 'remark',
|
|
'check_type', 'rail_width', 'rail_length',
|
|
'exit_direction', 'front_bottom_width', 'box_width', 'box_height',
|
|
'bar_width', 'bar_height',
|
|
'components', 'material_summary',
|
|
'search_keyword', 'registration_date', 'options',
|
|
'is_active', 'created_by', 'updated_by',
|
|
];
|
|
|
|
protected $casts = [
|
|
'components' => 'array',
|
|
'material_summary' => 'array',
|
|
'options' => 'array',
|
|
'is_active' => 'boolean',
|
|
'registration_date' => 'date',
|
|
'rail_width' => 'decimal:2',
|
|
'rail_length' => 'decimal:2',
|
|
'front_bottom_width' => 'decimal:2',
|
|
'box_width' => 'decimal:2',
|
|
'box_height' => 'decimal:2',
|
|
'bar_width' => 'decimal:2',
|
|
'bar_height' => 'decimal:2',
|
|
];
|
|
|
|
protected $hidden = ['deleted_at'];
|
|
|
|
public function files(): HasMany
|
|
{
|
|
return $this->hasMany(File::class, 'document_id')
|
|
->where('document_type', 'bending_model');
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
public const TYPE_GUIDERAIL = 'GUIDERAIL_MODEL';
|
|
public const TYPE_SHUTTERBOX = 'SHUTTERBOX_MODEL';
|
|
public const TYPE_BOTTOMBAR = 'BOTTOMBAR_MODEL';
|
|
}
|