본문 바로가기
카테고리 없음

laravel eloquent where문 () or and 처리

by 향유 2023. 1. 20.
eloquent
		->where('company_id', $companyId)
        ->where(function ($q){
            $q->whereIn('status', ['ongoing', 'partially'])
            ->whereIn('type', ['dine']); //테이블 겔제대기 or 부분결제
        })->orWhere(function($q){
            $q->whereIn('status', ['hold'])
            ->whereIn('type', ['takeout']); //보류   
        })
        ->orderBy('created_at', 'desc');


mysql
//       where ((status='onging' or status='partially') and  type='dind')
//          or ((status='hold') and type='takeout')

댓글