File: D:/HostingSpaces/SBogers95/rentman.io/app/Komma/Dynamic/ComponentType/Types/CustomerStorySlider.php
<?php
namespace App\Komma\Dynamic\ComponentType\Types;
use App\Komma\CustomerStories\Kms\CustomerStoryService;
use App\Komma\Dynamic\ComponentType\ComponentTypes;
use App\Komma\Kms\Core\Attributes\Attribute;
use App\Komma\Kms\Core\Attributes\Documents;
use App\Komma\Kms\Core\Attributes\OnOff;
use App\Komma\Kms\Core\Attributes\Select;
use App\Komma\Kms\Core\Attributes\TextArea;
use App\Komma\Kms\Core\Attributes\TextField;
class CustomerStorySlider extends AbstractComponentType
{
public function __construct()
{
parent::__construct();
//Set an id that corresponds to the ComponentTypes enum
$this->id = ComponentTypes::CUSTOMER_STORY_SLIDER;
//Set icon and name
$this->name = 'customer-story-slider';
// $this->attributes->push((new OnOff())
// ->setLabelText('Grey Background')
// ->setStyleClass('is-background-option')
// ->mapValueFrom(Attribute::ValueFromItself, 'grey_background'));
$this->attributes->push((new TextField('label'))
->mapValueFrom(Attribute::ValueFromItself, 'label'));
$this->attributes->push((new TextField('title'))
->mapValueFrom(Attribute::ValueFromItself, 'title'));
$customerStoryService = \App::make(CustomerStoryService::class);
$customerStories = $customerStoryService->getOptionsForSelect(false, true);
for ($i = 0; $i < 6; $i++) {
$this->translatableAttributes[] = 'description_'.($i + 1);
$this->translatableAttributes[] = 'person_'.($i + 1);
$this->attributes->push((new Select())
->setLabelText('Story')
->setItems($customerStories->toArray())
->mapValueFrom(Attribute::ValueFromItself, 'customer_story_'.($i + 1))
->setDataAttribute('tab', ($i + 1)));
$this->attributes->push((new TextArea())
->setLabelText('Overrule Description')
->setPlaceholderText('Ex. Lorum ipsum')
->mapValueFrom(Attribute::ValueFromItself, 'description_'.($i + 1))//Needed to sustain Attribute integrity.
->setDataAttribute('tab', ($i + 1)));
$this->attributes->push((new TextField('Person'))
->mapValueFrom(Attribute::ValueFromItself, 'person_'.($i + 1))//Needed to sustain Attribute integrity.
->setPlaceholderText('Ex. Roy van den Broek')
->setDataAttribute('tab', ($i + 1)));
$this->attributes->push((new Documents())
->setLabelText('Impression')
->onlyAllowImages()
->setSmallDragAndDropArea()
->setMaxDocuments(1)
->setSubFolder('customerStoryImpression')
->mapValueFrom(Attribute::ValueFromItself, 'image_'.($i + 1)) //Needed to sustain Attribute integrity.
->setDataAttribute('tab', ($i + 1)));
}
}
}