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/PricingLabels/PricingLabelComposer.php
<?php

namespace App\Komma\PricingLabels;

use App\Komma\PricingLabels\Models\PricingLabel;
use Illuminate\View\View;

class PricingLabelComposer
{
    public static $pricingLabels;

    private static function getLabels()
    {
        if (! isset(self::$pricingLabels)) {
            self::$pricingLabels = PricingLabel::with('translation')
                ->has('translation')
                ->get();
        }

        // Convert to collection
        $pricingLabelsTranslations = [];
        foreach (self::$pricingLabels as $pricingLabel) {
            $pricingLabelsTranslations[$pricingLabel->code_name] = $pricingLabel->translation->name;
        }

        return $pricingLabelsTranslations;
    }

    /**
     * Bind data to the view.
     *
     * @param View $view
     * @return void
     */
    public function compose(View $view)
    {
        $view->with('pricingLabels', (object) $this->getLabels());
    }

    public static function getVueTranslations()
    {
        return array_merge(__('site/vue'), self::getLabels());
    }
}