2017-09-15 102 views
0

如何在不使用Query之間獲取laravel中兩個日期之間的記錄。如何獲取laravel中兩個日期之間的記錄

我使用以下查詢來過濾記錄。只有我發佈的數據響應字段,過濾器是最新得到正確records.when後,迄今它沒有得到任何record.what的我的錯誤..

$q = Telecallerverification::query(); 

     $usersid = Auth::user()->id; 

     $q->Where('created_by',$usersid); 

     if ($request->input('frmdate_submit')) 
     { 
      $q->whereDate('created_at','<=',$request->input('frmdate_submit')); 
     } 

     if ($request->input('todate_submit')) 
     { 
      $q->whereDate('created_at','>=',$request->input('todate_submit')); 
     } 

     if ($request->input('response')) 
     { 
      $q->Where('leadsresponse',$request->input('response')); 
     } 

     $telecallerverifications = $q->orderBy('id','DESC')->paginate(25); 

回答

0

試試這個。希望它能幫助你。

$q = Telecallerverification::query(); 

    $usersid = Auth::user()->id; 

    $q->Where('created_by',$usersid); 

    if($request->input('frmdate_submit') && $request->input('todate_submit')){ 
     $q->whereBetween('created_at',array($request->input('frmdate_submit'),$request->input('todate_submit'))) 
    } 
    else if ($request->input('frmdate_submit')) 
    { 
     $q->whereDate('created_at','<=',$request->input('frmdate_submit')); 
    } 

    else if ($request->input('todate_submit')) 
    { 
     $q->whereDate('created_at','>=',$request->input('todate_submit')); 
    } 

    else if ($request->input('response')) 
    { 
     $q->Where('leadsresponse',$request->input('response')); 
    } 

    $telecallerverifications = $q->orderBy('id','DESC')->paginate(25); 
相關問題