Laravel 8: Assign many products to an order

  eloquent, laravel, relationship

I’m implementing a database fetching where an orders table saves different product ids in a column.

I wonder if this approach of storing all the products in a single column as an array is good enough or if I should implement an intermediate table storing order ids and products ids.

Or if there is an even better way to do this.

I know that I can itterate through an array to fetch the products info that way but I would like to make it more elegant using eloquent relationships.

Source: Laravel

Leave a Reply