ttl(), $resolver); } public function featuredLessons(): array { return Cache::remember(self::FEATURED_LESSONS_KEY, $this->ttl(), static fn (): array => AcademyLesson::query() ->with('category') ->active() ->published() ->where('featured', true) ->latest('published_at') ->limit(6) ->get() ->all()); } public function featuredPrompts(): array { return Cache::remember(self::FEATURED_PROMPTS_KEY, $this->ttl(), static fn (): array => AcademyPromptTemplate::query() ->with('category') ->active() ->published() ->where(function ($query): void { $query->where('featured', true)->orWhere('prompt_of_week', true); }) ->latest('published_at') ->limit(6) ->get() ->all()); } public function featuredChallenges(): array { return Cache::remember(self::FEATURED_CHALLENGES_KEY, $this->ttl(), static fn (): array => AcademyChallenge::query() ->publiclyVisible() ->where('featured', true) ->latest('starts_at') ->limit(6) ->get() ->all()); } public function categoriesByType(string $type): array { $cacheKey = self::CATEGORIES_KEY . '.' . $type; return Cache::remember($cacheKey, $this->ttl(), static fn (): array => AcademyCategory::query() ->active() ->where('type', $type) ->orderBy('order_num') ->orderBy('name') ->get() ->all()); } public function clearAll(): void { Cache::forget(self::HOME_KEY); Cache::forget(self::FEATURED_LESSONS_KEY); Cache::forget(self::FEATURED_PROMPTS_KEY); Cache::forget(self::FEATURED_CHALLENGES_KEY); foreach (['lesson', 'prompt', 'challenge', 'pack'] as $type) { Cache::forget(self::CATEGORIES_KEY . '.' . $type); } } private function ttl(): int { return max(60, (int) config('academy.cache.ttl', 1800)); } }