samedi 28 novembre 2015

Advanced Select statement (Laravel)

In the Products table i have the store_id column which connects the product with the store.

In my APIController which i use with Angular i have this return statement. I am returning a collection of products.

return Product::where('category_id', $category->id)->select(array('id',
                                                                        'name',
                                                                        'newprice',
                                                                        'image',
                                                                        'store_id',
                                                                        'link'))->paginate(20);

My problem is that instead of returning the store_id(from the products table) i want to return the store name, which is NOT stored in the same table. Is there any way to do that? Is my only option the use of JOIN?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire