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/farmfun.komma.pro/app/Komma/Products/ProductComposer.php
<?php

namespace App\Komma\Products;

use App\Komma\Products\Models\Product;
use Illuminate\View\View;

final class ProductComposer
{
    /** @var ProductService */
    private $productService;

    public function __construct()
    {
        $this->productService = app()->make(ProductService::class);
    }

    /**
     * Bind data to the view.
     *
     * @param View $view
     * @return void
     */
    public function experiences(View $view)
    {
        $products = Product::whereIn('code_name', ['farm_games', 'farm_trophy', 'farm_trophy_plus'])
            ->with('translation')
            ->get();

        $program = collect();

        foreach ($products as $product) {
            $program->push((object) [
                'product' => $product,
                'highlighted' => $product->code_name === 'farm_trophy',
                'price' => euro_pricing_format($product->price_each_unit),
                'price_ex' => euro_pricing_format($product->price_each_unit_excluding_vat),
                'max_persons' => $product->code_name === 'farm_games' ? 110 : 220,
                'min_persons' => $product->code_name === 'farm_games' ? 10 : 12,
            ]);
        }

        $view->with('program', $program);
    }

    public function firstProducts(View $view)
    {
        $view->with('highlightedProducts', $this->productService->getAmountOfProducts());
    }
}