File: D:/HostingSpaces/SBogers95/rentman.io/app/Komma/Shop/Categories/CategoryController.php
<?php
namespace App\Komma\Shop\Categories;
use App\Http\Controllers\Controller;
use App\Komma\Shop\Categories\Kms\CategoryService;
use App\Komma\Shop\Categories\Kms\CategoryServiceInterface;
use App\Komma\Shop\Categories\Models\Category;
class CategoryController extends Controller
{
private $pagePrefix = 'shop.pages.categories.';
private $categoryService;
public function __construct(CategoryServiceInterface $categoryService)
{
parent::__construct();
$this->categoryService = $categoryService;
}
/**
* @return \Illuminate\Contracts\View\View
*/
public function index()
{
$page = $this->pageService->getPageByCodeName('categories');
// $products = $this->categoryService->modelsWithoutGroups(); //All products that are not in groups or composites with their translation for the current language
// $groups = $this->groupService->modelsNotInComposites(); //All groups that are not in composites with their translation for the current language
// $composites = $this->compositeService->models(); //All composites
// $categoryTree = $this->categoryService->getModelTree($this->site->id)->getTree();
//TODO. Retrieving products like this is not the way to go. Thats why we are going to make a catalog thingy.
// Return view
return \View::make($this->pagePrefix.'index', [
'page' => $page,
'links' => $this->links,
// 'otherLanguages' => $otherLanguageRoutes,
// 'categoryTree' => $categoryTree,
]);
}
/**
* @return \Illuminate\Contracts\View\View
*/
public function filters()
{
$filters = request('filters');
var_dump('Filter posts with these filters:');
$page = $this->pageService->getPageByCodeName('categories');
$categoryTree = $this->categoryService->getModelTree($this->site->id)->getTree();
// Return view
return \View::make($this->pagePrefix.'index', [
'page' => $page,
'links' => $this->links,
'otherLanguages' => $otherLanguageRoutes,
'categoryTree' => $categoryTree,
]);
}
/**
* @param Page $page
* @return \Illuminate\Contracts\View\View
*/
public function show(Category $categoryTranslation)
{
$categoryTranslation->load('translation', 'sites');
// This checks if the post belongs to the set site
if (! $categoryTranslation->sites->contains($this->site)) {
throw abort(404);
}
$page = $this->pageService->getPageByCodeName('categories');
$category = $this->service->getModel($categoryTranslation->category_id);
$subCategories = $this->service->getModelsBetween($category->lft, $category->rgt, $this->site->id);
// Return view
return \View::make($this->baseViewPath.$this->pagePrefix.'show', [
'page' => $page,
'category' => $category,
'links' => $this->links,
'otherLanguages' => $otherLanguageRoutes,
]);
}
}