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/centrum8a/centrum8a.com/app/KommaApp/Shop/Products/ProductController.php
<?php

namespace App\KommaApp\Shop\Products;

use App\Http\Controllers\Controller;
use App\KommaApp\Shop\Catalog\Kms\CatalogService;
use App\KommaApp\Shop\Products\Product\Product;

class ProductController extends Controller
{
    private $pagePrefix = 'shop.pages.products.';
    private $catalogService;

    public function __construct(CatalogService $catalogService)
    {
        parent::__construct();
        $this->catalogService = $catalogService;
    }

    /**
     * @return \Illuminate\Contracts\View\View
     */
    public function index()
    {
        $page = $this->pageService->getPageByCodeName('products');
        $otherLanguageRoutes = $this->languageService->getOtherLanguagesRoutes($page);

        $allItems = $this->catalogService->getAllItems();

        // Return view
        return \View::make($this->pagePrefix.'index',[
            'page' => $page,
            'links' => $this->links,
            'otherLanguages' => $otherLanguageRoutes,
            'items' => $allItems,
        ]);
    }

    /**
     * @return \Illuminate\Contracts\View\View
     */
    public function filters()
    {
        $filters = request('filters');
        var_dump('Filter posts with these filters:');

        $page = $this->pageService->getPageByCodeName('products');
        $otherLanguageRoutes = $this->languageService->getOtherLanguagesRoutes($page);

        //$posts = $this->productService->getAllPosts(true);
        $products = $this->catalogService->modelsWithoutGroups(); //All products that are not in groups or composites with their translation for the current language

        // Return view
        return \View::make($this->pagePrefix.'index',[
            'page' => $page,
            'links' => $this->links,
            'otherLanguages' => $otherLanguageRoutes,
            'products' => $products,
        ]);
    }


    /**
     * @param Page $page
     * @return \Illuminate\Contracts\View\View
     */
    public function show(Product $product)
    {
        $product->load('translation', 'sites');

        // This checks if the post belongs to the set site
        if(! $product->sites->contains(\App::getSite())) throw abort(404);

        $page = $this->pageService->getPageByCodeName('products');
        $otherLanguageRoutes = $this->languageService->getOtherLanguagesRoutes($page, $product);

        // Return view
        return \View::make($this->baseViewPath.$this->pagePrefix.'show',[
            'page' => $page,
            'product' => $product,
            'links' => $this->links,
            'otherLanguages' => $otherLanguageRoutes
        ]);
    }

}