首页 > 代码库 > 使用laravel 生成 带括号的sql

使用laravel 生成 带括号的sql

laravel query builder use where case
 
I want to  sql like that :
 
select * from `wxm_ticket` where `wxm_ticket`.`deleted_at` is null and `user_id` = ? and `sell_status` = ? and (`stop_sell` is null or `stop_sell` >= ?)

 

 
php code:
 
$query = TicketModel::user($admin_id)->sellStatus(1)->where(function($query){$query->orWhereNull(‘stop_sell‘)->orWhere(‘stop_sell‘, ‘>=‘, \Carbon\Carbon::now());});;