【已解决】Laravel 5一个页面多个分页解决

原创文章,转载请注明: 转载自勤奋的小青蛙
本文链接地址: 【已解决】Laravel 5一个页面多个分页解决

需求:页面上有两个甚至多个分页,Laravel如何解决?

laravel_page1 laravel_page2

解决方案:

Controller:

$hotted_questions = Question::orderBy('votes', 'desc')->paginate(5, ['*'], 'hotted_page');
        $latest_questions = Question::orderBy('updated_at', 'asc')->paginate(5, ['*'], 'latest_page');
        return view('frontend.qalist', compact('hotted_questions', 'latest_questions', 'current_active_item'));

View:

{{$latest_questions->appends(array_except(Request::query(), 'latest_page'))->links()}}
{{$hotted_questions->appends(array_except(Request::query(), 'hotted_page'))->links()}}

 

 

原创文章,转载请注明: 转载自勤奋的小青蛙
本文链接地址: 【已解决】Laravel 5一个页面多个分页解决

文章的脚注信息由WordPress的wp-posturl插件自动生成



|2|left
打赏

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: