<?php

namespace App\Http\Controllers\Api\Admin;

use App\Http\Controllers\Controller;
use App\Models\Report;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

final class ModerationReportQueueController extends Controller
{
    public function index(Request $request): JsonResponse
    {
        $status = (string) $request->query('status', 'open');
        $status = in_array($status, ['open', 'reviewing', 'closed'], true) ? $status : 'open';

        $items = Report::query()
            ->with('reporter:id,username')
            ->where('status', $status)
            ->orderByDesc('id')
            ->paginate(30);

        return response()->json($items);
    }
}
