vendredi 25 septembre 2015

The Idea behind HasManyThrough in Eloquent

I'm standing infront of a, in my opinion, complex szenario.

I am using Laravel 5 and Eloquent ORM. Imagine the following tables: - company_orders - orders

The company_orders table should store additional data, which is only relevant for company orders and is also needed cause many orders can be grouped in one company order. The orders table stores all information to the specific order.

The question is now: I would have created a third table company_orders_to_orders to connect the respective order with the company_order entry. Is it right to use "HasManyThrough" or do you have a better idea? The table structure is like this:

company_orders

ID - Company_ID - SOMEMOREINFORMATION

orders

ID - User_ID - SOMEMOREINFORMATION

company_orders_to_orders (if requiered)

ID - Company_Order_ID - Order_ID

Thanks for you help!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire