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/stafa.nl/app/Komma/Components/ComponentType/Types/TestimonialComponent.php
<?php


namespace App\Komma\Components\ComponentType\Types;

use App\Komma\Components\Component\ViewComponent;
use App\Komma\Components\ComponentType\ComponentTypes;
use App\Komma\Kms\Core\Attributes\Attribute;
use App\Komma\Kms\Core\Attributes\MultiSelect;
use App\Komma\Kms\Core\Attributes\OnOff;
use App\Komma\Kms\Core\Attributes\Seperator;
use App\Komma\Kms\Core\Attributes\Title;
use App\Komma\Testimonials\Models\Testimonial;
use App\Komma\Testimonials\Kms\TestimonialService;

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

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

        $testimonialsService = \App::make(TestimonialService::class);
        $selectTestimonialOptions = $testimonialsService->getOptionsForSelect(false, true);

        parent::__construct();

        $this->attributes->push((new MultiSelect())
            ->setLabelText('Testimonial')
            ->setItems($selectTestimonialOptions->toArray())
            ->setMaxItemsToSelect(1)
            ->canBeLinkedWith(Testimonial::class)
            ->mapValueFrom(Attribute::ValueFromComponent, 'testimonials')
        );

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

        $this->attributes->push((new OnOff())
            ->setLabelText("Getinte achtergrondkleur")
            ->mapValueFrom(Attribute::ValueFromComponent, 'shadedBackground')
        );

    }

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


}