Laratrust\Traits\LaratrustUserTrait::cachedRoles PHP 메소드

cachedRoles() 공개 메소드

Tries to return all the cached roles of the user and if it can't bring the roles from the cache, it would bring them back from the DB
public cachedRoles ( ) : Illuminate\Database\Eloquent\Collection
리턴 Illuminate\Database\Eloquent\Collection
    public function cachedRoles()
    {
        $cacheKey = 'laratrust_roles_for_user_' . $this->getKey();
        return Cache::remember($cacheKey, Config::get('cache.ttl', 60), function () {
            return $this->roles()->get();
        });
    }