Show links() with collection

Published 3 months ago by haizone

Hi I marge a few collection And I use forPage() function to show a limit in the collection Now I whant to show page to switch like ->links() But is don’t work How I show the links in marge collection??

Bakanyaka

You need to manually make html for that and generate url for each page to pass page as query string, then accept it and pass to your forPage() method in the controller . Or you can use https://github.com/spatie/laravel-collection-macros#paginate

haizone

@Bakanyaka thanks i use that: one more, what do u think about what i m doning here its ok?(for speed and all)

    $related = new Collection();
    $related = $related->merge($business->reviews()->where('approved',true)->get());

    foreach ($business->branches()->get() as $branch) {
      $related = $related->merge($branch->reviews()->get());
    }

Please sign in or create an account to participate in this conversation.