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/brameda/brameda.nl/app/Komma/Shop/Orders/OrderController.php
<?php

namespace App\Komma\Shop\Orders;

use App\Komma\Base\Controller;
use App\Komma\Shop\Orders\Kms\OrderService;
use App\Komma\Shop\Orders\Kms\OrderServiceInterface;
use App\Komma\Shop\Orders\Models\Order;

class OrderController extends Controller
{
    private $pagePrefix = 'shop.pages.orders.';
    private $orderService;

    public function __construct(OrderServiceInterface $orderService)
    {
        parent::__construct();
        $this->orderService = $orderService;
    }

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

//        $products = $this->orderService->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

//        $orderTree = $this->orderService->getModelTree($this->site->id)->getTree();

        //TODO. Retrieving products like this is not the way to go. That's why we are going to make a catalog thingy.

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


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

        // This checks if the post belongs to the set site
        if(! $orderTranslation->sites->contains($this->site)) throw abort(404);

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

        $order = $this->service->getModel($orderTranslation->order_id);
        $subOrders = $this->service->getModelsBetween($order->lft, $order->rgt, $this->site->id);

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

}