vendredi 8 juin 2018

Realizing SQL substatements in Laravel

I have a Database where every Order has a reference to a Customer which has a reference to a User. Every Order has one Customer and every Customer has one User. Now I would like to access all the Orders that are belonging to a User. In SQL I would write:

SELECT * FROM orders WHERE customer_id IN (SELECT id from customers WHERE user_id = 1)

How can I access them in Laravel without using SQL. Thank You!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire