- FormRequest 패턴 적용 (CategoryFieldStoreRequest, CategoryFieldUpdateRequest)
- Service에서 Validator::make() 제거
- Controller 메시지 i18n 키로 변경 (__('message.category_field.*'))
- is_required 타입을 'Y'/'N' → boolean으로 통일
- Swagger 스키마 is_required boolean 타입으로 업데이트
- Model scopeRequired() boolean 조건으로 변경
40 lines
916 B
PHP
40 lines
916 B
PHP
<?php
|
|
|
|
namespace App\Models\Commons;
|
|
|
|
use App\Traits\BelongsToTenant;
|
|
use App\Traits\ModelTrait;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class CategoryField extends Model
|
|
{
|
|
use BelongsToTenant, ModelTrait, SoftDeletes;
|
|
|
|
protected $table = 'category_fields';
|
|
|
|
protected $fillable = [
|
|
'tenant_id', 'category_id',
|
|
'field_key', 'field_name', 'field_type',
|
|
'is_required', 'sort_order', 'default_value', 'options', 'description',
|
|
'created_by', 'updated_by', 'deleted_by',
|
|
];
|
|
|
|
protected $casts = [
|
|
'is_required' => 'boolean',
|
|
'sort_order' => 'integer',
|
|
'options' => 'array',
|
|
];
|
|
|
|
public function category()
|
|
{
|
|
return $this->belongsTo(Category::class);
|
|
}
|
|
|
|
// 편의 스코프
|
|
public function scopeRequired($q)
|
|
{
|
|
return $q->where('is_required', true);
|
|
}
|
|
}
|