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');
}
}