2017-10-02 9 views
2

これをlaravel 5.1の雄弁に変換する方法を教えてください。 $ rest_idと$ shop_idは変数です。ネストされた生のクエリをlaravelに変換します。

WHERE 
    `orderbookings`.`status` = 1 AND 
    ((`shop_customer_details`.`restaurant_id` = $rest_id AND `shop_customer_details`.`shop_id` = $shop_id) OR 
    `orderbookings`.`shop_customer_detail_id` = 0) AND 
    `orderbookings`.`id` LIKE '%ODRID201709181700343052%' 

答えて

2

このコードを試してみてください。

->where('orderbookings.status', 1) 
->where(function($q) use ($rest_id, $shop_id) { 
     $q->where(function($query) use ($rest_id, $shop_id) { 
       $query->where('shop_customer_details.restaurant_id', $user_id) 
         ->where('shop_customer_details.shop_id', $shop_id); 
      }) 
      ->orWhere('orderbookings.shop_customer_detail_id', 0) 
     }) 
->where('orderbookings.id', 'like', '%ODRID201709181700343052%') 
関連する問題