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/carrot.komma.pro/app/Komma/Composers/ServicePointComposer.php
<?php


namespace App\Komma\Composers;


use Illuminate\View\View;

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


        // If the translation can't be found, fallback to first translation that does exist
        if ($viewData['servicepoint']->translation == null){
            $viewData['servicepoint']->translation = $viewData['servicepoint']->translations->first();
        }

        if(
            $viewData['servicepoint']->documents &&
            count($viewData['servicepoint']->documents) > 0 &&
            $viewData['servicepoint']->documents[0]->small_image_url
        ) {
            $servicepointImage = $viewData['servicepoint']->documents[0]->small_image_url;
        } else {
            $servicepointImage = '/img/placeholder-person.svg';
        }

        if($viewData['servicepoint']->translation) {
            $servicepointFirstName = $viewData['servicepoint']->translation->first_name;
            $servicepointLastName = $viewData['servicepoint']->translation->last_name;
            $servicepointFunction = $viewData['servicepoint']->translation->function;
            $servicepointEmail = $viewData['servicepoint']->translation->email;
            $servicepointTelephoneLabel = $viewData['servicepoint']->translation->telephone_label;
            $servicepointTelephoneUrl = $viewData['servicepoint']->translation->telephone_url;
        } else {
            $servicepointFirstName = null;
            $servicepointLastName = null;
            $servicepointFunction = null;
            $servicepointEmail = null;
            $servicepointTelephoneLabel = isset($viewData['phoneDisplay']) ?: null;
            $servicepointTelephoneUrl = isset($viewData['phoneCall']) ?: null;
        }

        $view->with('servicepointImage', $servicepointImage);
        $view->with('servicepointFirstName', $servicepointFirstName);
        $view->with('servicepointLastName', $servicepointLastName);
        $view->with('servicepointFunction', $servicepointFunction);
        $view->with('servicepointEmail', $servicepointEmail);
        $view->with('servicepointTelephoneLabel', $servicepointTelephoneLabel);
        $view->with('servicepointTelephoneUrl', $servicepointTelephoneUrl);
    }
}