mercredi 23 août 2017

Multiple Joins Same name Laravel

I have a question i have 4 tables

Deals
Lists
Lists_Galleries
List_has_deals
Lists_has_gallery

I need to obtain the img_src_list what is in the List_Galleries but from deals.

I have this var in this time

$query = ListsDeals::where( $matchDeals )
                    ->where('stock', '>', 0)
                    ->orwhere( $matchOtherDeals )
                    ->whereDate('end_date', '>', date('Y-m-d'))
                    ->limit( 4 )
                    ->offset( 0 )
                    ->orderBy( 'start_date' );

$deals = $query->join( 'list_has_deals', 'deals.id', '=', 'list_has_deals.deal_id'  )
        ->join( 'lists', 'list_has_deals.list_id', '=', 'lists.id' )
        ->join( 'list_has_gallery', 'lists.id', '=', 'list_has_gallery.list_id' )
        ->join( 'lists_galleries', 'list_has_gallery.gallery_id', '=', 'lists_galleries.id' )->get();

This Give me the results but how i have the same name in all tables for example title for deals and lists that overwrite the names and dont get the values correct, how i can obtain certain columns without overwrite the others? regards.



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

Aucun commentaire:

Enregistrer un commentaire