File: D:/HostingSpaces/SBogers10/wingssprayer.komma.pro/app/Components/ComponentType/Types/Intro.php
<?php
namespace App\Components\ComponentType\Types;
use App\Components\ComponentType\ComponentTypes;
use Komma\KMS\Core\Attributes\Attribute;
use Komma\KMS\Core\Attributes\Documents;
use Komma\KMS\Core\Attributes\Models\ImageProperty;
use Komma\KMS\Core\Attributes\OnOff;
use Komma\KMS\Core\Attributes\Seperator;
use Komma\KMS\Core\Attributes\TextArea;
use Komma\KMS\Core\Attributes\TextField;
use Komma\KMS\Core\Attributes\Title;
class Intro extends AbstractComponentType
{
public function __construct()
{
//Set an id that corresponds to the ComponentTypes enum
$this->id = ComponentTypes::INTRO;
//Set icon and name
$this->name = 'intro';
parent::__construct();
$this->attributes->push(new Title(__('kms/attributes/components.text')));
$this->attributes->push((new TextField(__('kms/attributes/components.title')))
->mapValueFrom(Attribute::ValueFromComponent, 'title')
);
$this->attributes->push((new TextArea())
->enableTinymceEditor()
->mapValueFrom(Attribute::ValueFromComponent, 'description')
);
$this->attributes->push((new TextField(__('kms/attributes/components.button_link')))
->mapValueFrom(Attribute::ValueFromComponent, 'button_link')
);
$this->attributes->push((new TextField(__('kms/attributes/components.button_label')))
->mapValueFrom(Attribute::ValueFromComponent, 'button_label')
);
$this->attributes->push((new OnOff())
->setLabelText(__('kms/attributes/components.show_scroll_button'))
->mapValueFrom(Attribute::ValueFromComponent, 'show_scroll_button')
);
$this->attributes->push(new Seperator());
$this->attributes->push(new Title(__('kms/attributes/components.image')));
$this->attributes->push((new Documents())
->onlyAllowImages()
->setSubFolder('component_uploads')
->setMaxDocuments(1)
->setImageProperties([
(new ImageProperty())->setName('large')->setCropMethod(ImageProperty::Fit)->setWidth(1032)->setHeight(600),
(new ImageProperty())->setName('medium')->setCropMethod(ImageProperty::Fit)->setWidth(688)->setHeight(400),
(new ImageProperty())->setName('small')->setCropMethod(ImageProperty::Fit)->setWidth(430)->setHeight(250),
])
->setSmallDragAndDropArea()
->mapValueFrom(Attribute::ValueFromComponent, 'image') //Needed to sustain Attribute integrity.
);
$this->attributes->push((new TextField(__('kms/attributes/components.youtube_code')))
->mapValueFrom(Attribute::ValueFromComponent, 'youtube_code')
);
}
}