【问题标题】:Laravel 9 - Bootstrap Pagination & Sorting of displayed listLaravel 9 - 显示列表的引导分页和排序
【发布时间】:2022-11-11 11:55:48
【问题描述】:

我在 Laravel 9 中有一个简单的 StudentController,它有一个允许 BS 分页或排序的索引方法 -但不是两者.我怎样才能将两者结合起来?如何同时获得分页和排序列表?TIA

   // Display student list.
   public function index()
   {
        $students = Student::latest()->paginate(5);
        // $students = Student::orderBy('age', 'ASC')->get();
        return view('students.index',compact('students'));
   }

【问题讨论】:

  • $students = Student::latest()->orderBy('age', 'ASC')->paginate(5);

标签: laravel sorting pagination


【解决方案1】:

这可以帮助

$students=Student::latest()->orderBy('age', 'ASC')->paginate(5);

【讨论】:

    猜你喜欢
    • 2023-03-10
    • 2017-08-19
    • 2018-12-12
    • 2014-02-24
    • 2015-06-10
    • 2013-08-23
    • 1970-01-01
    • 2017-01-26
    • 2015-08-22
    相关资源
    最近更新 更多