如何在不使用Query之间的laravel中获取两个日期之间的记录。
我使用以下查询来过滤记录。只有我发布带有数据的响应字段,过滤器才能获得正确的记录。从日期和日期发布时,它没有得到任何记录。这是我的错误..
$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 :(得分:1)
试试这个。希望它会对你有所帮助。
$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);