Reputation: 41
I've followed this documnetation (https://laravel.com/docs/8.x/pagination) and made changes accordingly but still I am not able to paginate the required page.
This is my controller code:
public function showManageCourierAddress()
{
$viewdata = [];
$addressRepoObj = new \App\Repositories\Mongo\CourierAddressRepository();
$addressData = $addressRepoObj->getAddressList(0,(int)Session::get('organisation_id'));
$viewdata['addresslist'] = $addressData;
unset($addressData);
return view('frontend.admin.managecourieraddress', ['viewdata' => DB::table('viewdata')->paginate(15)]);
}
On the view laravel, I've added this :
{{ $viewdata->links() }}
Can anyone tell me where I'm going wrong? And what I should do?
Upvotes: 2
Views: 608
Reputation: 252
DB::table('viewdata')->paginate(15)
returns LengthAwarePaginator
instance, which implements these methods.
It is enought to call {{ $viewdata->links() }}
, and it should return whole html with pagination buttons and links. You just write some styles for existing classes, or use methods as mentioned above to create your own html with your own structure.
If I did not understand your problem, please reply in comment.
Upvotes: 1