$locationId=Auth::user()->location_id;
$parcelDetails = $this->model
->whereBetween('date',array($fromDate, $toDate))
->where('source_from',$locationId)
->orWhere('destination_to',$locationId)
->with('sourceFrom', 'destinationTo')
->paginate($perPage);
//get();
return $parcelDetails;
我希望得到的结果是我的source_from或destination_to与$ locationId匹配给定的日期。
答案 0 :(得分:0)
您可以使用nested where来完成该任务:
$locationId=Auth::user()->location_id;
$parcelDetails = $this->model
->whereBetween('date',array($fromDate, $toDate))
->where(function($q){
$q->where('source_from', $locationId);
$q->orWhere('destination_to', $locationId);
})
->with('sourceFrom', 'destinationTo')
->paginate($perPage);
//get();
return $parcelDetails;