I am trying to use paginate method for 12 records. I need 12 results where first 6 results comes in first page and the rest 6 results in second page. I used the below code in the controller,
$collection = User::take(12)->whereHas('roles', function($q) {
$q->where('slug', 'member');
}
)->where('status','1')->OrderBy('last_login','desc');
I used take() to get 12 records and used paginate(6) to display 6 results in one page as this,
$collection = $collection->paginate(6);
return View('preferred_matches')->with(array('collection'=>$collection));
In my view , I gave links like this,
{{ $collection->links() }}
But the take(12) is not working. 6 results appears in each page ,but more than 12 results are displaying. How can I use limited records for pagination. Thanks in advance.