sarga/packages/Webkul/Shop/src/Http/Controllers/SearchController.php

47 lines
1.1 KiB
PHP
Raw Normal View History

2018-10-28 13:23:20 +00:00
<?php
namespace Webkul\Shop\Http\Controllers;
2019-07-01 11:33:36 +00:00
use Webkul\Product\Repositories\SearchRepository;
2018-10-29 06:09:09 +00:00
2018-10-28 13:23:20 +00:00
/**
* Search controller
*
2019-08-08 00:23:28 +00:00
* @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
2018-10-28 13:23:20 +00:00
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
2019-07-01 11:33:36 +00:00
class SearchController extends Controller
2018-10-28 13:23:20 +00:00
{
2019-07-01 11:33:36 +00:00
/**
* SearchRepository object
*
* @var Object
*/
protected $searchRepository;
2018-10-29 06:09:09 +00:00
2019-07-01 11:33:36 +00:00
/**
* Create a new controller instance.
*
* @param \Webkul\Product\Repositories\SearchRepository $searchRepository
* @return void
*/
public function __construct(SearchRepository $searchRepository)
2018-10-28 13:23:20 +00:00
{
2019-07-01 11:33:36 +00:00
$this->searchRepository = $searchRepository;
2020-02-06 11:48:51 +00:00
parent::__construct();
2018-10-28 13:23:20 +00:00
}
/**
* Index to handle the view loaded with the search results
2019-08-19 09:30:24 +00:00
*
* @return \Illuminate\View\View
2018-10-28 13:23:20 +00:00
*/
public function index()
{
2019-07-01 11:33:36 +00:00
$results = $this->searchRepository->search(request()->all());
2018-10-29 06:09:09 +00:00
2019-07-01 11:33:36 +00:00
return view($this->_config['view'])->with('results', $results->count() ? $results : null);
2018-10-28 13:23:20 +00:00
}
}