src/models/UserOnline.php
public static function refreshUser(User $user, $route)
    {
        // skip the process if an api user is try to refresh.
        if ($user->is_api_user) {
            return;
        }
        
        $model = self::findOne(['user_id' => $user->id]);
        
        if ($model) {
            return (bool) $model->updateAttributes(['last_timestamp' => time(), 'invoken_route' => $route]);
        }
        
        $model = new self(['last_timestamp' => time(), 'user_id' => $user->id, 'invoken_route' => $route]);
        return $model->save();
    }
public static function refreshUser(User $user, $route)
    {
        // skip the process if an api user is try to refresh.
        if ($user->is_api_user) {
            return;
        }
        
        $model = self::findOne(['user_id' => $user->id]);
        
        if ($model) {
            return (bool) $model->updateAttributes(['last_timestamp' => time(), 'invoken_route' => $route]);
        }
        
        $model = new self(['last_timestamp' => time(), 'user_id' => $user->id, 'invoken_route' => $route]);
        return $model->save();
    }
public static function refreshUser ( User $ user , $ route ) { // skip the process if an api user is try to refresh. if ( $ user -> is_api_user ) { return ; } $ model = self :: findOne ( [ 'user_id' => $ user -> id ] ) ; if ( $ model ) { return ( bool ) $ model -> updateAttributes ( [ 'last_timestamp' => time ( ) , 'invoken_route' => $ route ] ) ; } $ model = new self ( [ 'last_timestamp' => time ( ) , 'user_id' => $ user -> id , 'invoken_route' => $ route ] ) ; return $ model -> save ( ) ; }
Refresh the state of the current user, or add if not exists.

@param User $user
@param string $route
@return bool
Refresh the state of the current user or add if not exists .