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

85 lines
1.9 KiB
PHP
Raw Normal View History

2018-07-12 07:12:48 +00:00
<?php
namespace Webkul\Shop\Http\Controllers;
2018-10-28 13:23:20 +00:00
use Webkul\Shop\Http\Controllers\Controller;
2019-04-18 07:22:51 +00:00
use Webkul\Core\Repositories\SliderRepository;
use Webkul\Product\Repositories\SearchRepository;
class HomeController extends Controller
2018-07-12 07:12:48 +00:00
{
2019-07-01 11:33:36 +00:00
/**
* SliderRepository object
*
2020-03-05 13:37:08 +00:00
* @var \Webkul\Core\Repositories\SliderRepository
2019-07-01 11:33:36 +00:00
*/
2019-04-18 07:22:51 +00:00
protected $sliderRepository;
2018-07-12 07:12:48 +00:00
/**
* SearchRepository object
*
* @var \Webkul\Core\Repositories\SearchRepository
*/
protected $searchRepository;
2019-07-01 11:33:36 +00:00
/**
* Create a new controller instance.
*
2020-03-05 13:37:08 +00:00
* @param \Webkul\Core\Repositories\SliderRepository $sliderRepository
* @param \Webkul\Product\Repositories\SearchRepository $searchRepository
2019-07-01 11:33:36 +00:00
* @return void
*/
public function __construct(
SliderRepository $sliderRepository,
SearchRepository $searchRepository
)
2018-07-12 07:12:48 +00:00
{
2019-04-18 07:22:51 +00:00
$this->sliderRepository = $sliderRepository;
2020-02-06 11:48:51 +00:00
$this->searchRepository = $searchRepository;
2020-02-06 11:48:51 +00:00
parent::__construct();
2018-07-12 07:12:48 +00:00
}
/**
* loads the home page for the storefront
2019-08-19 09:30:24 +00:00
*
* @return \Illuminate\View\View
*/
public function index()
{
2019-04-18 07:22:51 +00:00
$currentChannel = core()->getCurrentChannel();
2020-04-13 17:33:45 +00:00
$currentLocale = core()->getCurrentLocale();
$sliderData = $this->sliderRepository
->where('channel_id', $currentChannel->id)
->where('locale', $currentLocale->code)
->get()
->toArray();
2019-04-18 07:22:51 +00:00
return view($this->_config['view'], compact('sliderData'));
2018-07-12 07:12:48 +00:00
}
2019-04-23 07:13:42 +00:00
/**
* loads the home page for the storefront
2020-03-05 13:37:08 +00:00
*
* @return \Exception
2019-04-23 07:13:42 +00:00
*/
public function notFound()
{
abort(404);
}
/**
* Upload image for product search with machine learning
*
* @return \Illuminate\Http\Response
*/
public function upload()
{
$url = $this->searchRepository->uploadSearchImage(request()->all());
return $url;
}
2019-04-17 07:26:33 +00:00
}