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/shop.komma.nl/app/Products/ProductController.php
<?php

namespace App\Products;

use App\Products\Product\Product;
use App\Products\Product\ProductResource;
use Illuminate\Http\Resources\Json\Resource as JsonResource;

class ProductController extends ProductableController
{
    protected $pagePrefix = 'shop.pages.products.';
    protected $showViewName = 'templates.product';

    function makeResource(AbstractProductable $productable): JsonResource
    {
        return new ProductResource($productable);
    }

    protected function regularShow(AbstractProductable $productable)
    {
        /** @var Product $productable */
        $productGroup = $productable->groups()->where('group_products', '=', '1')->first();
        if($productGroup) {
            $this->showViewName = 'templates.product_group';
            $view = parent::regularShow($productGroup);
            $view->with('selectedProduct', $productable);
        } else {
            $view = parent::regularShow($productable);
        }

        return $view;
    }
}