File: D:/HostingSpaces/SBogers10/carrot.komma.pro/app/Komma/Components/ComponentType/Types/USP.php
<?php
namespace App\Komma\Components\ComponentType\Types;
use App\Komma\Buttons\Kms\ButtonService;
use App\Komma\Buttons\Models\Button;
use App\Komma\Components\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\MultiSelect;
use App\Komma\Kms\Core\Attributes\Seperator;
use App\Komma\Kms\Core\Attributes\TextField;
use App\Komma\Kms\Core\Attributes\Title;
class USP extends AbstractComponentType
{
public function __construct()
{
//Set an id that corresponds to the ComponentTypes enum
$this->id = ComponentTypes::USP;
//Set icon and name
$this->name = 'usp';
parent::__construct();
$this->attributes->push((new TextField('Titel'))
->mapValueFrom(Attribute::ValueFromComponent, 'header')
);
$this->attributes->push(new Seperator());
$this->attributes->push(new Title('Lijst'));
$this->attributes->push((new TextField('Regel 1'))
->mapValueFrom(Attribute::ValueFromComponent, 'USP1')
);
$this->attributes->push((new TextField('Regel 2'))
->mapValueFrom(Attribute::ValueFromComponent, 'USP2')
);
$this->attributes->push((new TextField('Regel 3'))
->mapValueFrom(Attribute::ValueFromComponent, 'USP3')
);
$this->attributes->push((new TextField('Regel 4'))
->mapValueFrom(Attribute::ValueFromComponent, 'USP4')
);
$this->attributes->push((new TextField('Regel 5'))
->mapValueFrom(Attribute::ValueFromComponent, 'USP5')
);
$this->attributes->push((new TextField('Regel 6'))
->mapValueFrom(Attribute::ValueFromComponent, 'USP6')
);
$this->attributes->push((new TextField('Regel 7'))
->mapValueFrom(Attribute::ValueFromComponent, 'USP7')
);
$buttonsService = \App::make(ButtonService::class);
$selectOptions = $buttonsService->getOptionsForSelect(false, true);
$this->attributes->push((new MultiSelect())
->setLabelText('Knop')
->setItems($selectOptions->toArray())
->setMaxItemsToSelect(1)
->canBeLinkedWith(Button::class)
->mapValueFrom(Attribute::ValueFromComponent, 'buttons')
);
$this->attributes->push(new Seperator());
$this->attributes->push(new Title('Afbeelding'));
$this->attributes->push((new Documents())
->onlyAllowImages()
->setSubFolder('component_uploads')
->setMaxDocuments(1)
->setImageProperties([
(new ImageProperty())->setName('large')->setCropMethod(ImageProperty::Fit)->setWidth(840),
])
->setSmallDragAndDropArea()
->mapValueFrom(Attribute::ValueFromComponent, 'image') //Needed to sustain Attribute integrity.
);
}
}