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-08-21 22:28:34 +09:00
|
|
|
use App\Traits\BelongsToTenant;
|
2025-11-06 17:45:49 +09:00
|
|
|
use App\Traits\ModelTrait;
|
2025-07-28 18:47:00 +09:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
|
|
2025-08-21 09:50:15 +09:00
|
|
|
/**
|
|
|
|
|
* @mixin IdeHelperMaterial
|
|
|
|
|
*/
|
2025-07-28 18:47:00 +09:00
|
|
|
class Material extends Model
|
|
|
|
|
{
|
2025-11-06 17:45:49 +09:00
|
|
|
use BelongsToTenant, ModelTrait, SoftDeletes;
|
2025-07-28 18:47:00 +09:00
|
|
|
|
2025-09-30 14:35:26 +09:00
|
|
|
protected $fillable = [
|
|
|
|
|
'tenant_id',
|
|
|
|
|
'category_id',
|
|
|
|
|
'name',
|
|
|
|
|
'item_name',
|
|
|
|
|
'specification',
|
|
|
|
|
'material_code',
|
2025-11-17 14:55:31 +09:00
|
|
|
'material_type',
|
2025-09-30 14:35:26 +09:00
|
|
|
'unit',
|
|
|
|
|
'is_inspection',
|
|
|
|
|
'search_tag',
|
|
|
|
|
'remarks',
|
|
|
|
|
'attributes',
|
|
|
|
|
'options',
|
|
|
|
|
'created_by',
|
|
|
|
|
'updated_by',
|
2025-11-17 14:55:31 +09:00
|
|
|
'is_active',
|
2025-09-30 14:35:26 +09:00
|
|
|
];
|
|
|
|
|
|
2025-08-21 22:28:34 +09:00
|
|
|
protected $casts = [
|
|
|
|
|
'attributes' => 'array',
|
2025-11-06 17:45:49 +09:00
|
|
|
'options' => 'array',
|
2025-11-17 14:55:31 +09:00
|
|
|
'is_active' => 'boolean',
|
2025-08-21 22:28:34 +09:00
|
|
|
];
|
2025-07-28 18:47:00 +09:00
|
|
|
|
2025-08-27 18:13:49 +09:00
|
|
|
protected $hidden = [
|
|
|
|
|
'deleted_at',
|
|
|
|
|
];
|
|
|
|
|
|
2025-07-28 18:47:00 +09:00
|
|
|
// 자재 입고 내역
|
|
|
|
|
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
|
|
|
}
|