mardi 28 juin 2016

Laravel 5 - query builder AND

i have a mysql query and i want to pass them to laravel but i don't know how to use AND in laravel.

Mysql:

SELECT * FROM `items_sizes` left join `items` on `items_sizes`.`id_item` = `items`.`id` left join `budget__items` on `items_sizes`.`id` = `budget__items`.`id_itemSize` and `budget__items`.`id_budget` = 1 where `items`.`active` = 1 and `budget__items`.`id_budget` is null order by `items_sizes`.`updated_at` asc

Laravel:

$itemsSizes = ItemsSize::leftJoin('items', 'items_sizes.id_item', '=','items.id')
        ->leftJoin('budget__items','items_sizes.id', '=', 'budget__items.id_itemSize')
        ->*AND*('budget__items.id_budget', '=', $id)
        ->where('items.active', '=', 1)
        ->whereNull('budget__items.id_budget')
        ->orderBy('items_sizes.updated_at', 'asc')

Thank's



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire