I have query like below, which fetch the records.
$posts = User::whereHas('roles', function($q)use($search){
$q->where('name', '=', 'agent')
->where('first_name', 'like', "%".$search."%")
->orWhere('last_name','like',"%".$search."%")
->orWhere('created_at','like',"%".$search."%");
})->limit($limit)
->orderBy($order,$dir)
->get();
I the above query I am using for pagination means to get next 10 records, but it does not working.
Following variables are posting from ajax
$limit = $request->input('length');
$start = $request->input('start');
$order = $columns[$request->input('order.0.column')];
$dir = $request->input('order.0.dir');
Ajax is working fine but I always get first 10 records when I submit for next 10 records. Can someone kindly help. Thank you
where()in that example, how it wraps awhere()andorWhere()clause? See if you can implement that.