Pregunta

I go through this but its not working properly

$orders = Paginator::make($orders, $total, $per_page);

I have 2000 records in data base from that i want to take only 200 records total and per page I want 10 record I am using full text match query.

$data=Item::raw_where("match (`name`) against ('*{$search_text}*' IN BOOLEAN MODE)")->where_value('verified')->order_by('created_at', 'DESC')->paginate(10);

guys can any one help me regarding this..thanx in advance

¿Fue útil?

Solución

Paginator::make($items, $total, $per_page) it has 3 parameters.

$items - record set of query result

$total - number of records into fetch result

$per_page - number of records per page you want

here, 2 step to perform manual pagination

step 1: count number of records first

$cc=Item::raw_where("match (`name`) against ('*{$search_text}*' IN BOOLEAN MODE)")->count();
if($cc>2000){$cc=2000;}
$per_page=200;
$page=Input::get('page',1);

step 2: paginate that records

$nn=Item::raw_where("match (`name`) against ('*{$search_text}*' IN BOOLEAN MODE)")->take($per_page)->skip(($page-1)*$per_page)->get();
$data=Paginator::make($nn, $cc, $per_page);

you will get paginated records in $data variable.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top