You may use the following code:
dd($your_query->toSql());
Then access the page and your code will halt execution and dump the query as SQL syntax.
By the way, for this exact query you exemplified, the following code works:
DB::table('product')
->join('price', 'product.productid', '=', 'price.productid')
->leftJoin('purchaseitem', 'product.productid', '=', 'purchaseitem.productid')
->where('product.name', '=', 'Superior King Room')
->whereNotBetween('purchaseitem.datestart', array('2014-01-06', '2014-01-07'))
->groupBy('product.productid')
->having(DB::raw('count(`purchaseitem`.`productid`)'), '<', 'product.quantity')
->take(30);
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community