Sql 将原始查询转换为嵌套位置上的laravel

Sql 将原始查询转换为嵌套位置上的laravel,sql,laravel,eloquent,Sql,Laravel,Eloquent,我如何将其转换为laravel 5.1 Elotent$rest\u id和$shop\u id是变量 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_

我如何将其转换为laravel 5.1 Elotent$rest\u id和$shop\u id是变量

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%'
请尝试以下代码:

->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%')