Getting all categories (parents) of the model.
1dump($product->categories);2 3// OR4dump($product->categories(['category type here', 'here too ...']));5 6// Returns Illuminate\Database\Eloquent\Collection
Getting the category (parent) of the model.
1dump($product->category);2// Returns Pharaonic\Laravel\Categorizable\Models\Category
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