dijkr / Copia

Laravel-project with CMS
0 stars 0 forks source link

Get collections from attributes #9

Closed dijkr closed 1 year ago

dijkr commented 1 year ago

This will create a collection with arrays. Every array contains arrays where every array is a row where the pluck value is equal. So basically nesting arrays.

This then could loop over each subcategory that contain products with the same subcategory. Once finished, it should loop over the next subcategory.

dijkr commented 1 year ago

Eventually its done with: $products = Product::where('category', $category)->get(); $groupedProducts = $products->groupBy('Subcategory'); The parents (keys) of its parent-array is called the value of the subcategory. So the indexed numbers are replaced by that.