Pharaonic
Loading...

# Model Parents

Getting all categories (parents) of the model.

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

# Model Single Parent

Getting the category (parent) of the model.

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

# Children Relationships

You can publish your config, migrations and you can find the config here : config/Pharaonic/categorizable.php.

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

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

Then you can get the category children like articles or products, etc...

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