This commit is contained in:
Mark Gregory
2026-07-24 10:30:36 +01:00
parent 10e9c25d6c
commit 395e4dc545
94 changed files with 619 additions and 160 deletions
+12
View File
@@ -0,0 +1,12 @@
<?php
namespace Modules\Categories\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
final class Category extends Model
{
protected $fillable = ['parent_id','name','slug','description','type','sort_order','is_active'];
protected function casts(): array { return ['is_active'=>'boolean','sort_order'=>'integer']; }
public function parent(): BelongsTo { return $this->belongsTo(self::class, 'parent_id'); }
public function children(): HasMany { return $this->hasMany(self::class, 'parent_id')->orderBy('sort_order'); }
}