<?php

namespace App\Http\Controllers;

use App\Repositories\ActivityLogRepository;
use App\Repositories\WebsiteRepository;
use Illuminate\Http\Request;
use Illuminate\View\View;

class SearchController extends Controller
{
    public function __invoke(
        Request $request,
        WebsiteRepository $websites,
        ActivityLogRepository $activityLogs,
    ): View {
        $term = trim((string) $request->string('q'));

        return view('search.index', [
            'term' => $term,
            'websites' => $websites->search($term),
            'activity' => $activityLogs->search($term),
        ]);
    }
}
