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()); });;
使用laravel 生成 带括号的sql
时间: 2024-10-10 22:16:01