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/netwerkbrabant.komma.pro/app/KommaApp/Search/SearchController.php
<?php


namespace App\KommaApp\Search;


use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;

class SearchController extends Controller
{
    private $searchService;

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

    public function show()
    {

        $query = \Input::get('q');

        // If there isn't a query defined return the view without any variables
        if(empty($query)) return \View::make($this->baseViewPath.'.pages.search');


        //Check if query is a tag
        if($redirectResponse = $this->searchService->ifQueryIsTag($query) ) return $redirectResponse;


        $searchResults = $this->searchService->searchForQuery($query);

        // Return view
        return \View::make($this->baseViewPath.'.pages.search',[
            'searchQuery' => $query,
            'searchResults' => $searchResults,
        ]);

    }
}