Level 12
all credit to this guy
https://youtu.be/4yfRdl2-3mE
on the app provider add
use Illuminate\Support\Collection;
use Illuminate\Pagination\Paginator;
use Illuminate\Pagination\LengthAwarePaginator;
//on boot
public function boot()
{
if (!Collection::hasMacro('paginate')) {
Collection::macro('paginate',
function ($perPage = 5, $page = null, $options = []) {
$page = $page ?: (Paginator::resolveCurrentPage() ?: 1);
return (new LengthAwarePaginator(
$this->forPage($page, $perPage), $this->count(), $perPage, $page, $options))
->withPath('');
});
}
}
this code paginate the collections
then call on the blade this code
// after foreach
<div class="row">
<div class="col-12 text-center">
{{ $invoices->links() }}
</div>
</div>
that will make the magic!
all credit to this guy
https://youtu.be/4yfRdl2-3mE
Please or to participate in this conversation.