Search code examples
phpcodeigniterstatichmvc

Creating a method accessible from all controllers


I need to make a model method which can be accessed from all other controllers, regardless of parents and modules.

I'm using CodeIgniter and HMVC patterns, if that have anything to say.

What I am looking for is identical to static classes/methods in Java

Edit: I need this to check wether a user is online or not. Putting it in the User Model will not suffice, as I need to check if a user is online in plenty other modules


Solution

  • class User
    {
        public static function is_online($user) { }
    }
    
    $online = User::is_online($user);