显示函数名称的日期过滤器必须是字符串错误

时间:2018-06-08 09:56:53

标签: php laravel laravel-5.5 php-7.1

我试图在我的控制器中添加日期搜索过滤器,但始终显示错误"功能名称必须是字符串" 附加图片。

注意:我的控制器已经有2个工作搜索过滤器,其中一个是搜索框第二个是下拉列表

See Image

控制器:

 public function index(Request $request)
{
   //this for search box
    $search=$request->input('search'); 

  // this for drop down list
    if(request()->has('lead_status')){

        $leads=Lead::where('lead_status', request('lead_status'))
        ->paginate(5)
        ->appends('lead_status',request('lead_status'));
    }
    // this for date search from and to
    if($search()->has('from') && $search()->has('to'))
        {
            $from_date = date('Y-m-d', strtotime($search()->has('from')));
            $to_date = date('Y-m-d', strtotime($search()->has('to')));
            $leads = Lead::whereBetween('created_at', [$from_date, $to_date]);
        }

    else{

        $leads=Lead::orderBy('created_at','desc')->search($search)->paginate(5);

    }

    return  view ('leads.index')->with('leads',$leads);

}

0 个答案:

没有答案