<?php

namespace App\Http\Controllers\Api\v1;

use App\Dictionary\CountryDictionary;
use App\Helpers\ApiResponse;
use App\Http\Controllers\Controller;
use App\Models\Bot;
use App\Models\BotLog;
use App\Models\Injection;
use Illuminate\Http\JsonResponse;

class FilterController extends Controller
{
            ->groupBy('application')
            ->with('injection')
            ->orderBy('application')
            ->limit(10)
            ->get();

        $applications = $logs->groupBy(function (BotLog $log) {
            return $log->type;
        });

        /** @var Bot|null $bot */
        $bot = Bot::select('created_at')
            ->orderByDesc('created_at')
            ->first();

        $start_date = $bot?->created_at
            ?->format('Y-m-d H:i:s');

        $filters = [
            'countries' => $countries,
            'injections' => $injections,
            'start_date' => $start_date,
            'applications' => $applications,
        ];

        return ApiResponse::success($filters);
    }
}
