Answer the question
In order to leave comments, you need to log in
Is it possible to rebuild the collection?
There is a Category model and a Product model. There is a many-to-many relationship between these models. On the category page, we get all the products of this category and, for each product, all of its categories.
Example.
$category->type
$category->name
@foreach ($category->products as $product)
$product->name
@foreach ($product->categories as $category)
$category->type
$category->name
@endforeach
@endforeach
Manufacturer
Alize
Alize Lana Gold
Manufacturer
Alize
Country
Turkey
Fiber
Acrylic
$category->type
$category->name
@foreach ($category->products as $product)
$product->country // категория
$product->manufacturer // категория
$product->name
@foreach ($product->fibers as $fiber) // категория
$fiber->name
@endforeach
@endforeach
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question