<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Services\GlobalSearchService;

class SearchController extends Controller
{
    public function globalSearch(Request $request, GlobalSearchService $searchService)
    {
        $term = $request->input('q');
        
        if (strlen($term) < 2) {
            return response()->json([]);
        }

        $results = $searchService->search($term);

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