- Material 모델 - fillable 속성 추가 (모든 필드 명시) - User 모델 - BelongsToMany 관계 타입 힌트 추가 - Product 모델 - fillable에 unit 필드 추가 - casts 순서 정리 (boolean 그룹화) - ProductComponent 모델 - quantity 캐스트 정밀도 변경 (decimal:4 → decimal:6) - referencedItem() 메서드 추가 (동적 관계 로드) - product(), material() 관계 메서드 수정 (where 조건 추가) - is_default 캐스트 제거 (컬럼 없음) - Tenant 모델 - options 캐스트 추가 (array) - scopeActive() 추가 (trial, active 상태 필터링) - isActive(), isTrial() 헬퍼 메서드 추가 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
71 lines
1.4 KiB
PHP
71 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Materials;
|
|
|
|
use App\Models\Commons\File;
|
|
use App\Models\Commons\Tag;
|
|
use App\Models\Qualitys\Lot;
|
|
use App\Traits\ModelTrait;
|
|
use App\Traits\BelongsToTenant;
|
|
use Filament\Forms\Components\Hidden;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
/**
|
|
* @mixin IdeHelperMaterial
|
|
*/
|
|
class Material extends Model
|
|
{
|
|
use SoftDeletes, ModelTrait, BelongsToTenant;
|
|
|
|
protected $fillable = [
|
|
'tenant_id',
|
|
'category_id',
|
|
'name',
|
|
'item_name',
|
|
'specification',
|
|
'material_code',
|
|
'unit',
|
|
'is_inspection',
|
|
'search_tag',
|
|
'remarks',
|
|
'attributes',
|
|
'options',
|
|
'created_by',
|
|
'updated_by',
|
|
];
|
|
|
|
protected $casts = [
|
|
'attributes' => 'array',
|
|
'options' => 'array',
|
|
];
|
|
|
|
protected $hidden = [
|
|
'deleted_at',
|
|
];
|
|
|
|
// 자재 입고 내역
|
|
public function receipts()
|
|
{
|
|
return $this->hasMany(MaterialReceipt::class, 'material_id');
|
|
}
|
|
|
|
// 로트 관리
|
|
public function lots()
|
|
{
|
|
return $this->hasMany(Lot::class, 'material_id');
|
|
}
|
|
|
|
// 파일 목록 (N:M, 폴리모픽)
|
|
public function files()
|
|
{
|
|
return $this->morphMany(File::class, 'fileable');
|
|
}
|
|
|
|
// 태그 목록 (N:M, 폴리모픽)
|
|
public function tags()
|
|
{
|
|
return $this->morphToMany(Tag::class, 'taggable');
|
|
}
|
|
}
|