Files
sam-api/app/Models/BendingModel.php
강영보 25db0df38b fix: [절곡] bending_models lot_no 제거 — legacy_code로 이관
- bending_models에는 LOT 개념 없음, lot_no 컬럼 불필요
- lot_no 값 → legacy_code로 이관 후 컬럼 DROP
- BendingModel fillable에서 lot_no 제거
- GuiderailModelResource에서 lot_no 제거
- BendingModelImport: lot_no → legacy_code
- 마이그레이션 rollback 로직 수정
2026-03-21 15:39:09 +09:00

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';
}