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/komma.pro/app/KommaApp/Shop/Orders/OrderController.php
<?php

namespace App\KommaApp\Shop\Orders;

use App\Http\Controllers\Controller;
use App\KommaApp\Shop\Orders\Kms\OrderService;
use App\KommaApp\Shop\Orders\Kms\OrderServiceInterface;
use App\KommaApp\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(\App::getSite()->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::make($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(\App::getSite())) 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, \App::getSite()->id);

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

}