I made a Laravel project where Category, Subcategory and Child category working using same table relation. I want to show all products from childcategory when click to Main Category. So for that I need to use multiple foreach loop like this,
foreach ($categories->subcategories as $subcat)
{
foreach ($subcat->childcategories as $childcat )
{
$products = $childcat->products;
}
}
Now I want to send $products to a view. How can I do it. I don't want to use array. How can I send It. Please help.