enzer's avatar
Level 1

How Change Pagination Number Mode to Load More Button

Hello i want change Pagination Number mode to Load more button. Please Help me change this

This is my Controller.php

public function index() { //$Topmusics = Post::orderBy('download_count', 'DESC')->paginate(13); $FeaturedMusics = Post::orderBy('id','desc')->paginate(30); return view('Pages.Music.index',compact('FeaturedMusics'));

}
/**
 * Display the specified resource.
 *
 * @param  int  $slug
 * @return \Illuminate\Http\Response
 */
public function show($slug)
{
    // This query to get Music page //
    $Music = Post::where('slug', '=', $slug)->firstOrFail();
    //To Get All Music recents OUT SIDE IN HOME VIEW

    // $TrendMusics = Post::latest()->paginate(6);//update by sandun
    $ArtistSong = Post::where('slug', '=', $slug)->firstOrFail();

    $audio_data = Audio::where('id', '=', $ArtistSong->seo_title)->firstOrFail();

    $artist_data = Artist::where('id', '=', $audio_data->artist_id)->firstOrFail();

    $MusicList = Post::where('Title_en', 'like', '%'.$artist_data->name.'%')->latest()->paginate(6);

  $FeaturedMusics =  Post::orderBy('id','desc')->paginate(30);


    if(count($MusicList) < 2){
        $TrendMusics = Post::orderBy('download_count', 'desc')->paginate(6);
    }else{
        $TrendMusics = Post::where('Title_en', 'like', '%'.$artist_data->name.'%')->latest()->paginate(12); // new update from artist
    }

    // dd(count($TrendMusics));
    //To Get Comments
    $Comments = $Music->Comments;
    // To Get Change The Language
    return view('Pages.Music.show',compact('Music','TrendMusics','Comments'));

Blade.php

    {{ $FeaturedMusics->links() }}
0 likes
1 reply
Yarad's avatar

Your backend shouldn't know or automatically recognize, what page is queried. Thats why it should be handled by frontend part: just put current loaded page to some js variable and increment and request next page every time.

P.S. Although in context of your question backend can stay unchanged, maybe you should reorganize it a bit for optimisation/codestyling issues.

Please or to participate in this conversation.