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/SBogers10/rentman2019.komma.pro/app/Komma/Shop/Products/ProductController.php
<?php

namespace App\Komma\Shop\Products;

use App\Http\Controllers\Controller;
use App\Komma\Shop\Catalog\Kms\CatalogService;
use App\Komma\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');

        $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');

        //$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($this->site)) {
            throw abort(404);
        }

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

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