mardi 5 juillet 2016

Multiple pagination in a single page - Laravel v 5.*

I have some videos and categories associated to it. I loop for each category and get all the category details along with the videos associated with that category.

I want to show all the categories videos in a single page, here i want pagination for each category.

Am getting a pagination numbers correctly i mean if i paginate by 5 if one category has 25 videos it shows 5 links , but the problem here is either when i click one pagination all other pagination are also effecting or nothing is effecting.

Code i tried so far,

Controller part,

    foreach ($categories as $category){
    $category_videos[] = Videos::where('category_id',$category->id)->paginate(3, ['*'], $category->category_name);
}return view('allcategories')->withVideos($category_videos);

View part,

{!!  $videos[$catCount]->render() !!}

here $catCount is the count of categories.

Am rendering this after each category in my view in a for loop.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire