فرعوني
جاري التحميل...

# آباء Model

الحصول على كل الأقسام (الآباء) الخاصة بـ Model.

1dump($product->categories);
2 
3// OR
4dump($product->categories(['category type here', 'here too ...']));
5 
6// Returns Illuminate\Database\Eloquent\Collection

# الأب الوحيد لـ Model

الحصول على القسم الخاص بـ الـ Model.

1dump($product->category);
2// Returns Pharaonic\Laravel\Categorizable\Models\Category

# العلاقات مع أبناء القسم

يمكنك نشر config, migrations وستجد الإعدادات هنا : config/Pharaonic/categorizable.php.

1php artisan vendor:publish --tag=laravel-categorizable

1return [
2 'children' => [
3 'products' => App\Models\Product::class,
4 ]
5];

ومن ثم يمكنك الحصول على أبناء القسم مثل المقالات أو المنتجات إلخ...

1dump($category->products);
2// Returns Illuminate\Database\Eloquent\Collection