File: D:/HostingSpaces/netwerkbrabant/netwerkbrabant.nl/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,
]);
}
}