File: D:/HostingSpaces/Neopoints/momsecurity.be/database/seeds/Components.php
<?php
use App\Komma\Dynamic\ComponentType\ComponentType;
use App\Komma\Dynamic\ComponentType\ComponentTypeBuilder;
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\Video;
use App\Komma\Users\Kms\UserService;
use App\Komma\Users\Models\User;
use Illuminate\Database\Seeder;
class Components extends Seeder
{
public function run()
{
//Build a component type that has two textarea's
$componentTypeBuilder = (new ComponentTypeBuilder());
/** @var ComponentType $doubleText */
$doubleTextComponent = $componentTypeBuilder
->setName('double-text')
->setIcon('two-column-block.svg')
->addAttribute(
(new TextArea())
->enableTinymceEditor()
->setLabelText('Linker kolom')
->mapValueFrom(Attribute::ValueFromItself, 'FieldOne') //Needed to sustain Attribute integrity.
)
->addAttribute(
(new TextArea())
->enableTinymceEditor()
->setLabelText('Rechter kolom')
->mapValueFrom(Attribute::ValueFromItself, 'FieldTwo') //Needed to sustain Attribute integrity.
)
->build();
//Build a component type that has one text area and one image
$componentTypeBuilder = (new ComponentTypeBuilder());
/** @var ComponentType $doubleText */
$textImageComponent = $componentTypeBuilder
->setName('text-image')
->setIcon('content-block.svg')
->addAttribute(
(new TextArea())
->enableTinymceEditor()
->setLabelText('Tekst')
->mapValueFrom(Attribute::ValueFromItself, 'Text') //Needed to sustain Attribute integrity.
)
->addAttribute(
(new Documents())
->setLabelText('Plaatje')
->onlyAllowImages()
->setSubFolder('component_uploads')
->setMaxDocuments(1)
->setImageProperties([
(new ImageProperty())->setName('original')->setCropMethod(ImageProperty::Resize)->setWidth(2000),
(new ImageProperty())->setName('small')->setCropMethod(ImageProperty::Resize)->setWidth(300),
])
->mapValueFrom(Attribute::ValueFromItself, 'Image') //Needed to sustain Attribute integrity.
)->build();
//Build a component type that has 3 textareas spread over 3 tabs
$componentTypeBuilder = (new ComponentTypeBuilder());
$trippleTextComponent = $componentTypeBuilder
->setName('triple-text')
->setIcon('dynamic-tripple_text.svg')
->addAttribute(
(new TextArea())
->enableTinymceEditor()
->setLabelText('Tekst')
->mapValueFrom(Attribute::ValueFromItself, 'tt_1') //Needed to sustain Attribute integrity.
->setDataAttribute('tab', 'Eerste tab')
)->addAttribute(
(new TextArea())
->enableTinymceEditor()
->setLabelText('Tekst')
->mapValueFrom(Attribute::ValueFromItself, 'tt_2') //Needed to sustain Attribute integrity.
->setDataAttribute('tab', 'Tweede tab')
)
->addAttribute(
(new TextArea())
->enableTinymceEditor()
->setLabelText('Tekst')
->mapValueFrom(Attribute::ValueFromItself, 'tt_3') //Needed to sustain Attribute integrity.
->setDataAttribute('tab', 'Derde tab')
)->build();
//Build a component type that has 3 textareas spread over 3 tabs
$componentTypeBuilder = (new ComponentTypeBuilder());
$postComponent = $componentTypeBuilder
->linkableToModel(User::class, UserService::class.'@getOptionsForSelect')
->setName('post')
->setIcon('dynamic-post.svg')
->build();
//Build a component type that has one text area and one image
$componentTypeBuilder = (new ComponentTypeBuilder());
/** @var ComponentType $doubleText */
$quoteComponent = $componentTypeBuilder
->linkableToModel(User::class, UserService::class.'@getOptionsForSelect')
->setName('quote')
->setIcon('quote.svg')
->addAttribute(
(new TextArea())
->enableTinymceEditor()
->setLabelText('Citaat')
->mapValueFrom(Attribute::ValueFromItself, 'Quote') //Needed to sustain Attribute integrity.
)->build();
//Build a component type that has one textfield and a on off toggle
$componentTypeBuilder = (new ComponentTypeBuilder());
/** @var ComponentType $videoComponent */
$videoComponent = $componentTypeBuilder
->setName('video')
->setIcon('video-block.svg')
->addAttribute(
new Video('video')
)->build();
}
}