`
return $all_user = DB::select("SELECT *,
'STATUS' AS STAT,
CASE
WHEN TIMESTAMPDIFF(MINUTE, updated_at, NOW()) <= 1 THEN 'online'
WHEN (TIMESTAMPDIFF(MINUTE, updated_at, NOW()) > 720
AND TIMESTAMPDIFF(MINUTE, updated_at, NOW()) <= 30) THEN 'idle'
ELSE 'offline'
END AS user_status
FROM users")->paginate(20);
`
I'm expecting the result with paginate link. when i put
->paginate(20)it giving me Call to a member function paginate() on array error. please help
DB::select()executes the query immediately and returns an Array;[]->paginate()is not valid. UseDB::table('users')->select('...')->paginate(10)as the answer below suggests, or use a Model (User::selectRaw('...')->paginate(10))User::selectRaw('...')->paginate(10)is working for me 😊.