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/carrotps/carrotps.com/app/Komma/Components/ComponentType/Types/ContentPersonal.php
<?php


namespace App\Komma\Components\ComponentType\Types;

use App\Komma\Buttons\Kms\ButtonService;
use App\Komma\Buttons\Models\Button;
use App\Komma\Components\Component\ViewComponent;
use App\Komma\Kms\Core\Attributes\Seperator;
use App\Komma\Servicepoints\Kms\ServicepointService;
use App\Komma\Servicepoints\Models\Servicepoint;
use App\Komma\Kms\Core\Attributes\MultiSelect;
use App\Komma\Components\ComponentType\ComponentTypes;
use App\Komma\Kms\Core\Attributes\Attribute;
use App\Komma\Kms\Core\Attributes\TextArea;
use App\Komma\Kms\Core\Attributes\TextField;
use App\Komma\Kms\Core\Attributes\Title;

class ContentPersonal extends AbstractComponentType
{
    public function __construct()
    {
        //Set an id that corresponds to the ComponentTypes enum
        $this->id = ComponentTypes::CONTENT_PERSONAL;

        //Set icon and name
        $this->name = 'content-personal';

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

        $buttonsService = \App::make(ButtonService::class);
        $selectOptions = $buttonsService->getOptionsForSelect(false, true);

        parent::__construct();

        $this->attributes->push(new Title('Tekst'));

        $this->attributes->push((new TextField('Titel'))
            ->mapValueFrom(Attribute::ValueFromComponent, 'content_header')
        );

        $this->attributes->push((new TextArea())
            ->enableTinymceEditor()
            ->setLabelText('Tekst')
            ->mapValueFrom(Attribute::ValueFromComponent, 'content_text')
        );

        $this->attributes->push((new MultiSelect())
            ->setLabelText('Knop')
            ->setItems($selectOptions->toArray())
            ->setMaxItemsToSelect(1)
            ->canBeLinkedWith(Button::class)
            ->mapValueFrom(Attribute::ValueFromComponent, 'buttons')
        );

        $this->attributes->push(new Seperator());
        $this->attributes->push(new Title('Contactpersoon'));

        $this->attributes->push((new TextField('Titel'))
            ->mapValueFrom(Attribute::ValueFromComponent, 'personal_header')
        );

        $this->attributes->push((new MultiSelect())
            ->setLabelText('Contactpersoon')
            ->setItems($selectServicepointOptions->toArray())
            ->setMaxItemsToSelect(1)
            ->canBeLinkedWith(Servicepoint::class)
            ->mapValueFrom(Attribute::ValueFromComponent, 'servicepoints')
        );


    }

    public function prepare(ViewComponent $viewComponent)
    {
       $viewComponent->servicepoints->load('translations', 'documents');
    }
}