mercredi 25 novembre 2015

Laravel 5.1 DBQuery Join

I have two tables:

products: id, name, manufacturer myproducts:id, user_id, product_id

I know the user_id through my auth token. With this user_id token, would like to get the product_id and id from myproducts and then query the products table to get the name and manufacturer where product_id in mymproducts matches id in the products table. The goal is provide an editable list to the user that he/she can edit in myproducts table.

So far I have only able to do $productlist = DB:table('myproducts')->where('user_id', $userid)->get(); This returns all the products a user owns. But I am having trouble joining the tables to return the product data for each product owned by the user. Any suggestions?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire