File: D:/HostingSpaces/SBogers95/rentman.io/app/Komma/Dynamic/ComponentType/Types/TextImageTabs.php
<?php
namespace App\Komma\Dynamic\ComponentType\Types;
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\Models\ImageProperty;
use App\Komma\Kms\Core\Attributes\TextArea;
use App\Komma\Kms\Core\Attributes\TextField;
class TextImageTabs extends AbstractComponentType
{
public function __construct()
{
//Set an id that corresponds to the ComponentTypes enum
$this->id = ComponentTypes::TEXT_IMAGE_TABS;
//Set icon and name
$this->name = 'text-image-tabs';
parent::__construct();
$this->attributes->push((new TextField('Label'))
->setPlaceholderText('Label')
->mapValueFrom(Attribute::ValueFromItself, 'slider_label'));
$this->attributes->push((new TextField('Title'))
->setPlaceholderText('Title')
->mapValueFrom(Attribute::ValueFromItself, 'slider_title'));
for ($i = 0; $i < 5; $i++) {
$this->translatableAttributes[] = 'title_'.($i + 1);
$this->translatableAttributes[] = 'description_'.($i + 1);
$this->attributes->push((new TextField('Tab'))
->mapValueFrom(Attribute::ValueFromItself, 'title_'.($i + 1))//Needed to sustain Attribute integrity.
->setPlaceholderText('Ex. Av & Lighting')
->setDataAttribute('tab', ($i + 1))
);
$this->attributes->push((new Documents())
->setLabelText('image')
->onlyAllowImages()
->setSubFolder('component_uploads')
->setMaxDocuments(1)
->setImageProperties([
(new ImageProperty())->setName('original')->setCropMethod(ImageProperty::Resize)->setWidth(1200),
(new ImageProperty())->setName('large')->setCropMethod(ImageProperty::Resize)->setWidth(900),
(new ImageProperty())->setName('medium')->setCropMethod(ImageProperty::Resize)->setWidth(600),
(new ImageProperty())->setName('small')->setCropMethod(ImageProperty::Resize)->setWidth(375),
])
->setSmallDragAndDropArea()
->setDataAttribute('tab', ($i + 1))
->mapValueFrom(Attribute::ValueFromItself, 'image_'.($i + 1)));
$this->attributes->push((new TextArea())
->setLabelText('Description')
->enableTinymceEditorOnClick()
->setPlaceholderText('Ex. Lorum ipsum')
->mapValueFrom(Attribute::ValueFromItself, 'description_'.($i + 1))//Needed to sustain Attribute integrity.
->setDataAttribute('tab', ($i + 1)));
}
}
}