Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

NadeemAkhter's avatar

class function use in where query

in my user class i have function isOnline(), it return boolean

public function isOnline() 
    {
        return Cache::has('user-is-online' . $this->id);
    }

i want to query get all online members . how i use this function inside query ??

User::where('here i need code which check isOnline  return true or false')->get();
0 likes
2 replies
NadeemAkhter's avatar

@CYTUS - thanks for reply. in this article they get all users and then they check which is online or not but i want to get only those users which are online. because in my project users may be in millions so i want to get only online users instead of get all users.

Please or to participate in this conversation.