samedi 28 novembre 2015

Advanced Select statement (Laravel)

I am returning a collection of products. 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.

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. Is there any way to do that?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1MLOmkg
via IFTTT

Aucun commentaire:

Enregistrer un commentaire