public function getUserId()
    {
        if (
            \Yii::$app !== null
            && \Yii::$app->has('user', true)
            && \Yii::$app->getUser() !== null
        ) {
            $user = \Yii::$app->getUser()->getIdentity(false);
            if ($user !== null) {
                return $user->getId();
            }
        }
        return null;
    }
public function getUserId()
    {
        if (
            \Yii::$app !== null
            && \Yii::$app->has('user', true)
            && \Yii::$app->getUser() !== null
        ) {
            $user = \Yii::$app->getUser()->getIdentity(false);
            if ($user !== null) {
                return $user->getId();
            }
        }
        return null;
    }
public function getUserId ( ) { if ( \ Yii :: $ app !== null && \ Yii :: $ app -> has ( 'user' , true ) && \ Yii :: $ app -> getUser ( ) !== null ) { $ user = \ Yii :: $ app -> getUser ( ) -> getIdentity ( false ) ; if ( $ user !== null ) { return $ user -> getId ( ) ; } } return null ; }
Returns the user identity ID.
@return int|string|null user identity ID, `null` if not available.
Returns the user identity ID .