2025-07-28 18:47:00 +09:00
|
|
|
<?php
|
|
|
|
|
|
2025-07-29 13:00:25 +09:00
|
|
|
namespace App\Models\Materials;
|
2025-07-28 18:47:00 +09:00
|
|
|
|
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;
|
2025-07-28 18:47:00 +09:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
|
|
|
|
|
|
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');
|
|
|
|
|
}
|
2025-07-28 18:47:00 +09:00
|
|
|
}
|