File: D:/HostingSpaces/SBogers95/rentman.io/app/Komma/Dynamic/ComponentType/Types/CarouselImages.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\OnOff;
class CarouselImages extends AbstractComponentType
{
public function __construct()
{
//Set an id that corresponds to the ComponentTypes enum
$this->id = ComponentTypes::CAROUSEL_IMAGES;
//Set icon and name
$this->name = 'carousel-images';
parent::__construct();
$this->attributes->push((new OnOff())
->setLabelText('Grey Background')
->setStyleClass('is-background-option')
->mapValueFrom(Attribute::ValueFromItself, 'grey_background'));
$this->attributes->push((new Documents())
->setLabelText('Images')
->onlyAllowImages()
->setSubFolder('component_uploads')
->setMaxDocuments(15)
->setImageProperties([
(new ImageProperty())->setName('large')->setCropMethod(ImageProperty::Resize)->setWidth(800),
(new ImageProperty())->setName('medium')->setCropMethod(ImageProperty::Resize)->setWidth(600),
(new ImageProperty())->setName('small')->setCropMethod(ImageProperty::Resize)->setWidth(375),
])
->setSmallDragAndDropArea()
->mapValueFrom(Attribute::ValueFromItself, 'image') //Needed to sustain Attribute integrity.
);
}
}