HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/blije-gasten.komma.pro/app/Komma/Shop/Search/SearchController.php
<?php


namespace App\Komma\Shop\Search;


use App\Komma\Base\Controller;
use App\Komma\Globalization\RegionInfoInterface;

class SearchController extends Controller
{

    /** @var SearchService $searchService */
    private $searchService;

    public function __construct()
    {
        parent::__construct();
        $this->searchService = app()->make(SearchService::class);
    }

    public function show()
    {
        //Return the parameters from the request
        $searchTerm = request()->input(config('site.search_key'));

        if(!isset($searchTerm)) {
            return view('site.templates.search_empty', [
                'links' => $this->links,
            ]);
        }

        $searchedModels = $this->searchService->searchByTerm($searchTerm);
        $searchResults = $this->searchService->convertModelsIntoSearchResults($searchedModels, $this->links);

        $searchResultCategories = $searchResults->groupBy('shortName');

        $regionInfo = app(RegionInfoInterface::class);

        // Return view
        return view('site.templates.search', [
            'results' => $searchResults,
            'resultCategories' => $searchResultCategories,
            'searchTerm' => $searchTerm,
            'links' => $this->links,
            'regionInfo' => $regionInfo
        ]);
    }
}