<?php

declare(strict_types=1);

namespace App\Controllers;

use App\Core\BaseController;
use App\Core\Request;
use App\Core\Response;
use App\Helpers\AjaxResponse;
use App\Services\GlobalSearchService;

final class SearchController extends BaseController
{
    public function search(Request $request): Response
    {
        $query = (string) $request->query('q', '');
        $results = (new GlobalSearchService())->search($query);

        return AjaxResponse::success($results);
    }
}
