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/bomacon/bomacon.nl/app/WebsiteConfig/WebsiteConfigSection.php
<?php

namespace App\WebsiteConfig;

use App\Buttons\Kms\ButtonService;
use App\Servicepoints\Kms\ServicepointService;
use App\Servicepoints\Models\Servicepoint;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
use Komma\KMS\Core\Attributes\Attribute;
use Komma\KMS\Core\Attributes\Documents;
use Komma\KMS\Core\Attributes\Models\ImageProperty;
use Komma\KMS\Core\Attributes\MultiSelect;
use Komma\KMS\Core\Attributes\Seperator;
use Komma\KMS\Core\Attributes\TextField;
use Komma\KMS\Core\Attributes\Title;
use Komma\KMS\Core\Sections\Section;
use Komma\KMS\Core\Sections\Tabs\Collections\NoLanguageTabs;
use Komma\KMS\Users\Models\KmsUserRole;

class WebsiteConfigSection extends Section
{
    protected $title = 'Website';
    protected $subTitle = 'Configurations';
    protected $slug = 'websiteconfig';

    public $showSave = 'all';         // Options: 'all' | 'admin' (SuperAdmin only) | 'none' (or anything else what isn't all or admin)
    public $showDelete = 'admin';
    public $showCreate = 'admin';


    /**
     * PageSection constructor.
     * @param $slug
     */
//    function __construct(Kms $kms, PageRepository $repository)
    public function __construct($slug)
    {
        $tabs = new NoLanguageTabs();
        parent::__construct($tabs, $slug);
    }

    /**
     * Generates the attributes for this section. They all must extend the Komma\KMS\Core\Attributes\Attribute class
     *
     * @param Model $currentModel
     * @return \Illuminate\Support\Collection A collection of SectionTabItems
     */
    protected function generateAttributes(Model $currentModel = null): Collection
    {
        //*****************************************************************************************\\
        //*** Generate the attributes                                                           ***\\
        //*****************************************************************************************\\
        $attributes = [];

        $attributes[] = (new Title('Bedrijfsgegevens'))
            ->setMinimumUserRole(KmsUserRole::Admin);

        $attributes[] = (new TextField('Url'))
            ->mapValueFrom(Attribute::ValueFromModel, 'company_url')
            ->setMinimumUserRole(KmsUserRole::Admin);

        $attributes[] = (new TextField('Bedrijfsnaam'))
            ->mapValueFrom(Attribute::ValueFromModel, 'company_name')
            ->setMinimumUserRole(KmsUserRole::Admin);

        $attributes[] = (new TextField('Adres'))
            ->mapValueFrom(Attribute::ValueFromModel, 'company_address')
            ->setMinimumUserRole(KmsUserRole::Admin);

        $attributes[] = (new TextField('Postcode'))
            ->mapValueFrom(Attribute::ValueFromModel, 'company_zip')
            ->setMinimumUserRole(KmsUserRole::Admin);

        $attributes[] = (new TextField('Stad'))
            ->mapValueFrom(Attribute::ValueFromModel, 'company_city')
            ->setMinimumUserRole(KmsUserRole::Admin);

        $attributes[] = (new TextField('Land'))
            ->mapValueFrom(Attribute::ValueFromModel, 'company_country')
            ->setMinimumUserRole(KmsUserRole::Admin);

        $attributes[] = (new TextField('KVK'))
            ->mapValueFrom(Attribute::ValueFromModel, 'company_kvk')
            ->setMinimumUserRole(KmsUserRole::Admin);

        $attributes[] = (new TextField('E-mail'))
            ->mapValueFrom(Attribute::ValueFromModel, 'company_email')
            ->setMinimumUserRole(KmsUserRole::Admin);

        $attributes[] = (new TextField('Telefoon link'))
            ->mapValueFrom(Attribute::ValueFromModel, 'company_phone_call')
            ->setMinimumUserRole(KmsUserRole::Admin);

        $attributes[] = (new TextField('Telefoon weergave'))
            ->mapValueFrom(Attribute::ValueFromModel, 'company_phone_display')
            ->setMinimumUserRole(KmsUserRole::Admin);

        $attributes[] = (new Seperator())
            ->setMinimumUserRole(KmsUserRole::Admin);

        $attributes[] = (new Title('Sociale media'))
            ->setMinimumUserRole(KmsUserRole::Admin);

        $attributes[] = (new TextField('Facebook'))
            ->mapValueFrom(Attribute::ValueFromModel, 'company_social_facebook')
            ->setMinimumUserRole(KmsUserRole::Admin);

        $attributes[] = (new TextField('Linkedin'))
            ->mapValueFrom(Attribute::ValueFromModel, 'company_social_linkedin')
            ->setMinimumUserRole(KmsUserRole::Admin);

        $attributes[] = (new TextField('Instagram'))
            ->mapValueFrom(Attribute::ValueFromModel, 'company_social_instagram')
            ->setMinimumUserRole(KmsUserRole::Admin);

        $attributes[] = (new TextField('Twitter'))
            ->mapValueFrom(Attribute::ValueFromModel, 'company_social_twitter')
            ->setMinimumUserRole(KmsUserRole::Admin);

        $attributes[] = (new Seperator())
            ->setMinimumUserRole(KmsUserRole::Admin);

        $attributes[] = (new Title(__('KMS::kms/global.cta')))
            ->setMinimumUserRole(KmsUserRole::SuperAdmin);

        $attributes[] = (new TextField('CTA Heading'))
            ->mapValueFrom(Attribute::ValueFromModel, 'global_CTA_heading')
            ->setMinimumUserRole(KmsUserRole::SuperAdmin);

        $servicepointService = \App::make(ServicepointService::class);
        $servicepointOptions = $servicepointService->getOptionsForSelect(false, true);

        $attributes[] = (new MultiSelect())
            ->setItems($servicepointOptions->toArray())
            ->setLabelText(__('CTA contactpersoon'))
            ->setMaxItemsToSelect(1)
            ->canBeLinkedWith(Servicepoint::class)
            ->mapValueFrom(Attribute::ValueFromModel, 'global_CTA_servicepoint_id')
            ->setMinimumUserRole(KmsUserRole::SuperAdmin);

        $buttonsService = \App::make(ButtonService::class);
        $buttonModels = $buttonsService->getOptionsForSelect();

        $attributes[] = (new MultiSelect())
            ->setItems($buttonModels->toArray())
            ->setMaxItemsToSelect(1)
            ->setLabelText('CTA Button')
            ->mapValueFrom(Attribute::ValueFromModel, 'global_CTA_button_id')
            ->setMinimumUserRole(KmsUserRole::SuperAdmin);

        $attributes[] = (new Seperator())
            ->setMinimumUserRole(KmsUserRole::SuperAdmin);

        $attributes[] = (new Title(__('KMS::kms/global.logos')))
            ->setMinimumUserRole(KmsUserRole::SuperAdmin);

        $attributes[] = (new Documents())
            ->setLabelText(__('KMS::kms/global.logo_on_light'))
            ->onlyAllowImages()
            ->setSmallDragAndDropArea()
            ->setMaxDocuments(1)
            ->setSubFolder('home')
            ->setImageProperties([
                (new ImageProperty())->setName('small')->setCropMethod(ImageProperty::Fit)->setWidth(147)->setHeight(48),
            ])
            ->mapValueFrom(Attribute::ValueFromDocuments, 'logo_on_light')
            ->setMinimumUserRole(KmsUserRole::SuperAdmin);

        $attributes[] = (new Documents())
            ->setLabelText(__('KMS::kms/global.logo_on_dark'))
            ->onlyAllowImages()
            ->setSmallDragAndDropArea()
            ->setMaxDocuments(1)
            ->setSubFolder('home')
            ->setImageProperties([
                (new ImageProperty())->setName('small')->setCropMethod(ImageProperty::Fit)->setWidth(152)->setHeight(50),
            ])
            ->mapValueFrom(Attribute::ValueFromDocuments, 'logo_on_dark')
            ->setMinimumUserRole(KmsUserRole::SuperAdmin);

        $attributes[] = (new Seperator())
            ->setMinimumUserRole(KmsUserRole::SuperAdmin);

        $attributes[] = (new Title(__('KMS::kms/global.hero')))
            ->setMinimumUserRole(KmsUserRole::SuperAdmin);

        $attributes[] = (new Documents())
            ->setLabelText(__('KMS::kms/global.images'))
            ->onlyAllowImages()
            ->setSmallDragAndDropArea()
            ->setMaxDocuments(5)
            ->setSubFolder('home')
            ->setImageProperties([
                (new ImageProperty())->setName('large')->setCropMethod(ImageProperty::Fit)->setWidth(1152)->setHeight(640),
                (new ImageProperty())->setName('medium')->setCropMethod(ImageProperty::Fit)->setWidth(920)->setHeight(460),
                (new ImageProperty())->setName('small')->setCropMethod(ImageProperty::Fit)->setWidth(837)->setHeight(465),
            ])
            ->mapValueFrom(Attribute::ValueFromDocuments, 'home_heroes')
            ->setMinimumUserRole(KmsUserRole::SuperAdmin);

        $attributes[] = (new TextField(__('KMS::kms/global.heroTitle')))
            ->mapValueFrom(Attribute::ValueFromTranslationModel, 'home_hero_title')
            ->setMinimumUserRole(KmsUserRole::SuperAdmin);

        $attributes[] = (new Seperator())
            ->setMinimumUserRole(KmsUserRole::SuperAdmin);


        //Return all attributes as a collection
        $attributes = collect(array_merge($attributes));

        return $attributes;
    }
}