<?php
declare(strict_types=1);

namespace App\Controllers;

use App\Core\Controller;
use App\Models\SearchModel;

final class SearchController extends Controller
{
    public function index(): void
    {
        require_permission('search.view');

        $q = trim((string) ($_GET['q'] ?? ''));
        $results = (new SearchModel())->search($q);

        $this->view('search/index', [
            'q' => $q,
            'results' => $results,
        ]);
    }
}
