all() returns a collection before you even get to slice() - paginate is a Builder method, so you will need to paginate off the query, e.g.
$countries = DB::table('countries')->skip(3)->paginate();
I was wondering how I would go about this?
Controller:
public function index()
{
$collection = Country::all();
$countries = $collection->slice(4);
return view('country.index', [
'countries' => $countries
]);
}
View:
<div class="row">
<div class="col-md-12">
<span class="pull-right">{{ $countries->links() }}</span>
</div>
</div>
Right now, I'm getting
Method links does not exist.
Which is understandable, since I didn't pass the pagination to the view, but if I do:
$countries = $collection->slice(4)->paginate(6);
Then:
Method paginate does not exist.
Presumably because the spice() method already returns the collection.
Please or to participate in this conversation.