82 lines
2.6 KiB
PHP
82 lines
2.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Controllers\Academy;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\AcademyPromptPack;
|
|
use App\Services\Academy\AcademyAccessService;
|
|
use App\Support\Seo\SeoFactory;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Str;
|
|
use Inertia\Inertia;
|
|
use Inertia\Response;
|
|
|
|
final class AcademyPromptPackController extends Controller
|
|
{
|
|
public function __construct(private readonly AcademyAccessService $access)
|
|
{
|
|
}
|
|
|
|
public function index(Request $request): Response
|
|
{
|
|
abort_unless((bool) config('academy.enabled', true), 404);
|
|
|
|
$packs = AcademyPromptPack::query()
|
|
->with('prompts')
|
|
->active()
|
|
->published()
|
|
->latest('published_at')
|
|
->paginate(12)
|
|
->withQueryString();
|
|
|
|
$packs->getCollection()->transform(fn (AcademyPromptPack $pack): array => $this->access->packPayload($pack, $request->user()));
|
|
|
|
$seo = app(SeoFactory::class)
|
|
->collectionListing(
|
|
'Academy Prompt Packs — Skinbase',
|
|
'Preview bundled prompt packs for Skinbase wallpapers, worlds, mascots, and editorial workflows.',
|
|
route('academy.packs.index'),
|
|
)
|
|
->toArray();
|
|
|
|
return Inertia::render('Academy/List', [
|
|
'pageType' => 'packs',
|
|
'title' => 'Prompt packs',
|
|
'description' => 'Curated prompt bundles with free previews and premium pack access tiers.',
|
|
'seo' => $seo,
|
|
'items' => $packs,
|
|
'filters' => [],
|
|
'categories' => [],
|
|
'pricingUrl' => route('academy.pricing'),
|
|
])->rootView('collections');
|
|
}
|
|
|
|
public function show(Request $request, string $slug): Response
|
|
{
|
|
abort_unless((bool) config('academy.enabled', true), 404);
|
|
|
|
$pack = AcademyPromptPack::query()
|
|
->with(['prompts.category'])
|
|
->active()
|
|
->published()
|
|
->where('slug', $slug)
|
|
->firstOrFail();
|
|
|
|
$payload = $this->access->packPayload($pack, $request->user(), true);
|
|
$seo = app(SeoFactory::class)->collectionPage(
|
|
$pack->title . ' — Skinbase Academy',
|
|
Str::limit((string) ($pack->excerpt ?? $pack->description ?? ''), 160, '...'),
|
|
route('academy.packs.show', ['slug' => $pack->slug]),
|
|
$pack->cover_image,
|
|
)->toArray();
|
|
|
|
return Inertia::render('Academy/Show', [
|
|
'pageType' => 'pack',
|
|
'item' => $payload,
|
|
'seo' => $seo,
|
|
'pricingUrl' => route('academy.pricing'),
|
|
])->rootView('collections');
|
|
}
|
|
} |