<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Models\Banner;
use Illuminate\Http\JsonResponse;

class BannerController extends Controller
{
    /**
     * Return all active banners, sorted by sort_order.
     * Public endpoint — no authentication required.
     */
    public function index(): JsonResponse
    {
        $banners = Banner::active()->get([
            'id', 'title', 'image_url', 'redirect_type', 'redirect_url', 'sort_order',
        ]);

        return response()->json(['data' => $banners]);
    }
}
