Files
sam-api/app/Models/Materials/Material.php

54 lines
1.2 KiB
PHP
Raw Normal View History

<?php
2025-07-29 13:00:25 +09:00
namespace App\Models\Materials;
2025-07-29 17:20:44 +09:00
use App\Models\Commons\File;
use App\Models\Commons\Tag;
2025-07-29 13:00:25 +09:00
use App\Models\Qualitys\Lot;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* @mixin IdeHelperMaterial
*/
class Material extends Model
{
use SoftDeletes;
// 자재(품목) 마스터
protected $fillable = [
'name', // 자재명(품명)
'specification', // 규격
'material_code', // 자재코드
'unit', // 단위
'is_inspection', // 검사대상 여부(Y/N)
'search_tag', // 검색 태그
'remarks', // 비고
];
// 자재 입고 내역
public function receipts()
{
return $this->hasMany(MaterialReceipt::class, 'material_id');
}
// 로트 관리
public function lots()
{
return $this->hasMany(Lot::class, 'material_id');
}
2025-07-29 13:00:25 +09:00
2025-07-29 17:20:44 +09:00
// 파일 목록 (N:M, 폴리모픽)
2025-07-29 13:00:25 +09:00
public function files()
{
return $this->morphMany(File::class, 'fileable');
}
2025-07-29 17:20:44 +09:00
// 태그 목록 (N:M, 폴리모픽)
public function tags()
{
return $this->morphToMany(Tag::class, 'taggable');
}
}