How to use pagination with laravel DB::select query

后端 未结 4 1017
醉梦人生
醉梦人生 2020-12-14 13:20

I am working on a project in Laravel and using DB facade to run raw queries of sql. In my case I am using DB::select, problem is that pagination method is not working with t

4条回答
  •  粉色の甜心
    2020-12-14 13:36

    Try:

    $notices = DB::table('notices')
            ->join('users', 'notices.user_id', '=', 'users.id')
            ->join('departments', 'users.dpt_id', '=', 'departments.id')
            ->select('notices.id', 'notices.title', 'notices.body', 'notices.created_at', 'notices.updated_at', 'users.name', 'departments.department_name')
            ->paginate(20);
    

提交回复
热议问题