File: D:/HostingSpaces/SBogers95/rentman.io/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());
}
}