D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
forge
/
re-viewers.com
/
app
/
Models
/
Filename :
Category.php
back
Copy
<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasMany; class Category extends Model { protected $table = 'categories'; protected $fillable = [ 'category_name', 'category_image', 'path', 'status', 'parent_id' ]; public function reviews(): HasMany { return $this->hasMany(Review::class); } public function parent() { return $this->belongsTo(Category::class, 'parent_id'); } // الأقسام الفرعية public function children() { return $this->hasMany(Category::class, 'parent_id'); } // أقسام متعددة المستويات public function allChildren() { return $this->children()->with('allChildren'); } }