<?php

namespace App\Http\Controllers\Api\V1;

use App\Http\Controllers\Controller;
use App\Http\Resources\StoryResource;
use App\Models\Story;
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
use OpenApi\Attributes as OA;

class StoryController extends Controller
{
    #[OA\Get(
        path: '/api/v1/stories',
        summary: 'Aktif hikayeleri listele',
        tags: ['Stories'],
        responses: [new OA\Response(response: 200, description: 'Hikaye listesi')],
    )]
    public function index(): AnonymousResourceCollection
    {
        $stories = Story::query()
            ->where('is_active', true)
            ->orderBy('order_index')
            ->get();

        return StoryResource::collection($stories);
    }
}
