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/stafa/werkenbijstafa.nl/app/Komma/Composers/ContentPersonalComposer.php
<?php


namespace App\Komma\Composers;


use App\Komma\Buttons\Models\Button;
use Illuminate\View\View;

class ContentPersonalComposer
{
    /**
     * @param View $view
     */
    public function compose(View $view)
    {
        $viewData = $view->getData();

        // Set button from global config settings
        $globalButton = Button::find(config('site.global_CTA_button_id'));
        $globalButtonText = null;
        $globalButtonLink = null;
        if(
            $globalButton &&
            $globalButton->translation
        ) {
            $globalButtonText = $globalButton->translation->label;
            $globalButtonLink = $globalButton->translation->url;
        }

        $view->with('globalButtonText', $globalButtonText);
        $view->with('globalButtonLink', $globalButtonLink);



        // Set button chosen in component
        $buttonText = null;
        $buttonLink = null;
        if(
            isset($viewData['component']) &&
            $viewData['component']->buttons &&
            count($viewData['component']->buttons) > 0 &&
            $viewData['component']->buttons[0]->translation
        ) {
            $button = $viewData['component']->buttons[0];
            $buttonText = $button->translation->label ?: null;
            $buttonLink = $button->translation->url ?: null;
        }

        $view->with('buttonText', $buttonText);
        $view->with('buttonLink', $buttonLink);
    }
}