public static function getRoleIdByAppIdAndUserId($app_id, $user_id)
    {
        $cacheKey = static::makeRoleIdCacheKey($app_id, $user_id);
        $result = \Cache::remember($cacheKey, \Config::get('df.default_cache_ttl'),
            function () use ($app_id, $user_id) {
                try {
                    return static::whereAppId($app_id)->whereUserId($user_id)->value('role_id');
                } catch (ModelNotFoundException $ex) {
                    return null;
                }
            });

        return $result;
    }
public static function getRoleIdByAppIdAndUserId($app_id, $user_id)
    {
        $cacheKey = static::makeRoleIdCacheKey($app_id, $user_id);
        $result = \Cache::remember($cacheKey, \Config::get('df.default_cache_ttl'),
            function () use ($app_id, $user_id) {
                try {
                    return static::whereAppId($app_id)->whereUserId($user_id)->value('role_id');
                } catch (ModelNotFoundException $ex) {
                    return null;
                }
            });

        return $result;
    }
public static function getRoleIdByAppIdAndUserId ( $ app_id , $ user_id ) { $ cacheKey = static :: makeRoleIdCacheKey ( $ app_id , $ user_id ) ; $ result = \ Cache :: remember ( $ cacheKey , \ Config :: get ( 'df.default_cache_ttl' ) , function ( ) use ( $ app_id , $ user_id ) { try { return static :: whereAppId ( $ app_id ) -> whereUserId ( $ user_id ) -> value ( 'role_id' ) ; } catch ( ModelNotFoundException $ ex ) { return null ; } } ) ; return $ result ; }
Use this primarily in middle-ware or where no session is established yet.
Once session is established, the role id is accessible via Session.

@param int $app_id
@param int $user_id

@return null|int The role id or null for admin
Use this primarily in middle - ware or where no session is established yet . Once session is established the role id is accessible via Session .