I am using laravel pagination but it is not working with query builder i have also refer the every answer of below stack url but it is also not working every answer showing a new error.Please help me to resolve this problem how i can used pagination with laravel query builder.I am using 5.3 version of laravel. Stack referal link=Laravel 5 Pagination with Query Builder
public function ajaxPagination(Request $request)
{
$query="SELECT users.`id`,users.`email`,users.`u_firstname`,users.`u_lastname`,users.`u_dob`,users.`u_mobile`,user_roles.`ur_role_id`,UCASE(master_roles.`role_name`) as roles,case users.`u_status` when '0' then 'Inactive' when '1' then 'Active' when '4' then 'Deactivate' end as status FROM `users` inner join user_roles on user_roles.`ur_user_id`=users.`id` inner join master_roles on user_roles.`ur_role_id`=master_roles.`role_id` where users.`id`!='$id' and users.`u_status`!='3' order by users.`id` desc";
$items = DB::select(DB::raw($query))->paginate(20);
var_dump($items);
die;
if ($request->ajax()) {
return view('data', compact('items'));
}
return view('items',compact('items'));
}
Error while using the above code Call to a member function paginate() on array