fix : Category, Product 관련 테이블 정리 (Models, DB, seeder)
This commit is contained in:
36
app/Models/Commons/CategoryField.php
Normal file
36
app/Models/Commons/CategoryField.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?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 SoftDeletes, BelongsToTenant, ModelTrait;
|
||||
|
||||
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', 1); }
|
||||
}
|
||||
Reference in New Issue
Block a user