Reputation: 1305
I have something like this:
http://pastebin.com/raw.php?i=jwcRskav
This data is not from database. How can I paginate it?
return view('admin/panel')->with('data', $n);
Upvotes: 0
Views: 2667
Reputation: 155
The data you've provided in the link is questionable, so I'd recommend you update your question with more information on this.
From the Laravel documentation:
Sometimes you may wish to create a pagination instance manually, passing it an array of items. You may do so by creating either an Illuminate\Pagination\Paginator or Illuminate\Pagination\LengthAwarePaginator instance, depending on your needs.
This could be done like so:
$paginated = Paginator::make($items, count($items), Input::get('limit') ?: '10');
Don't forget the use statement for the Paginator facade (use Paginator;
) at the top of your file.
Alternatively, you could make use of method dependancy injection:
public function someMethodName(Paginator $paginator)
{
$items = [];
return $paginator->make($items, count($items), Input::get('limit') ?: '10');
}
Upvotes: 1