2025-08-22 15:57:14 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models\Commons;
|
|
|
|
|
|
2026-01-29 15:33:54 +09:00
|
|
|
use App\Traits\Auditable;
|
2025-08-22 15:57:14 +09:00
|
|
|
use App\Traits\BelongsToTenant;
|
|
|
|
|
use App\Traits\ModelTrait;
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
|
|
|
|
|
|
class CategoryField extends Model
|
|
|
|
|
{
|
2026-01-29 15:33:54 +09:00
|
|
|
use Auditable, BelongsToTenant, ModelTrait, SoftDeletes;
|
2025-08-22 15:57:14 +09:00
|
|
|
|
|
|
|
|
protected $table = 'category_fields';
|
|
|
|
|
|
|
|
|
|
protected $fillable = [
|
2025-11-06 17:45:49 +09:00
|
|
|
'tenant_id', 'category_id',
|
|
|
|
|
'field_key', 'field_name', 'field_type',
|
|
|
|
|
'is_required', 'sort_order', 'default_value', 'options', 'description',
|
|
|
|
|
'created_by', 'updated_by', 'deleted_by',
|
2025-08-22 15:57:14 +09:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
protected $casts = [
|
|
|
|
|
'is_required' => 'boolean',
|
2025-11-06 17:45:49 +09:00
|
|
|
'sort_order' => 'integer',
|
|
|
|
|
'options' => 'array',
|
2025-08-22 15:57:14 +09:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
public function category()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(Category::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 편의 스코프
|
2025-11-06 17:45:49 +09:00
|
|
|
public function scopeRequired($q)
|
|
|
|
|
{
|
2025-11-14 13:45:54 +09:00
|
|
|
return $q->where('is_required', true);
|
2025-11-06 17:45:49 +09:00
|
|
|
}
|
2025-08-22 15:57:14 +09:00
|
|
|
}
|