File: D:/HostingSpaces/SBogers10/beerten.komma.nl/app/Vacancies/Kms/VacancySection.php
<?php
namespace App\Vacancies\Kms;
//The new object oriented attributes
use App\Buttons\Kms\ButtonService;
use App\Components\ComponentTypes;
use Illuminate\Database\Eloquent\Model;
use Komma\KMS\Core\Attributes\Attribute;
use Komma\KMS\Core\Attributes\ComponentArea;
use Komma\KMS\Core\Attributes\Models\ImageProperty;
use Komma\KMS\Core\Attributes\MultiSelect;
use Komma\KMS\Core\Attributes\Documents;
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;
use Komma\KMS\Core\Sections\Section;
use App\Servicepoints\Kms\ServicepointService;
use App\Servicepoints\Models\Servicepoint;
use Komma\KMS\Users\Models\KmsUserRole;
final class VacancySection extends Section
{
public function defineAttributesAndTabs(Model $currentModel = null): void
{
$servicePointService = \App::make(ServicepointService::class);
$servicePointOptions = $servicePointService->getOptionsForSelect(false, true);
$buttonsService = \App::make(ButtonService::class);
$buttonModels = $buttonsService->getOptionsForSelect();
$this->tabs->makeTab()->addItems([
(new OnOff())
->setLabelText(__('KMS::global.active'))
->switchOn()
->setReference( 'active'),
(new Seperator())->setMinimumUserRole(KmsUserRole::SuperAdmin),
(new Title())
->setLabelText(__('KMS::global.servicePoint'))
->setMinimumUserRole(KmsUserRole::SuperAdmin),
(new TextField())
->setLabelText('Titel')
->setMinimumUserRole(KmsUserRole::SuperAdmin)
->setReference( 'servicepoint_heading'),
(new MultiSelect())
->setItems($servicePointOptions->toArray())
->setLabelText(__('KMS::servicePoints.section.title'))
->setMaxItemsToSelect(1)
->canBeLinkedWith(Servicepoint::class)
->setMinimumUserRole(KmsUserRole::Admin)
->setReference( 'servicepoint_id'),
(new MultiSelect())
->setItems($buttonModels->toArray())
->setLabelText(__('KMS::global.button'))
->setMinimumUserRole(KmsUserRole::SuperAdmin)
->setMaxItemsToSelect(1)
->setReference( 'servicepoint_button_id')
]);
$this->tabs->makeLanguageTabTemplate()->addItems([
(new TextField())
->setLabelText(__('KMS::global.title'))
->setReference( 'name'),
(new Seperator()),
(new TextField())
->setLabelText(__('KMS::global.metaTitle'))
->setReference( 'meta_title'),
(new TextArea())
->setLabelText(__('KMS::global.metaDescription'))
->setReference( 'meta_description'),
(new Seperator())->setMinimumUserRole(KmsUserRole::SuperAdmin),
(new Title())
->setLabelText(__('KMS::global.hero'))
->setMinimumUserRole(KmsUserRole::SuperAdmin),
(new OnOff())
->setLabelText(__('KMS::global.active'))
->setMinimumUserRole(KmsUserRole::SuperAdmin)
->setReference( 'hero_active'),
(new TextField())
->setLabelText(__('KMS::global.heroTitle'))
->setMinimumUserRole(KmsUserRole::SuperAdmin)
->setReference( 'hero_title'),
(new TextArea())
->enableTinymceEditor()
->setLabelText(__('KMS::global.heroDescription'))
->setMinimumUserRole(KmsUserRole::SuperAdmin)
->setReference( 'hero_description'),
(new MultiSelect())
->setItems($buttonModels->toArray())
->setLabelText(__('KMS::global.button'))
->setMaxItemsToSelect(1)
->setMinimumUserRole(KmsUserRole::SuperAdmin)
->setReference( 'hero_button_id'),
(new Documents())
->setLabelText(__('KMS::global.images'))
->onlyAllowImages()
->setSmallDragAndDropArea()
->setMaxDocuments(5)
->setMinimumUserRole(KmsUserRole::SuperAdmin)
->setSubFolder('vacancies')
->setImageProperties([
(new ImageProperty())->setName('medium')->setCropMethod(ImageProperty::Resize)->setWidth(724),
(new ImageProperty())->setName('small')->setCropMethod(ImageProperty::Resize)->setWidth(359),
])
->setReference( 'vacancy_heroes'),
(new ComponentArea())
->setSubFolder('vacancy_component_data')
->setComponentTypes([
ComponentTypes::TEXT,
ComponentTypes::IMAGE,
ComponentTypes::TEXT_IMAGE_BUTTON,
ComponentTypes::VIDEO,
ComponentTypes::USP,
ComponentTypes::QUOTE,
ComponentTypes::CONTENT_PERSONAL,
ComponentTypes::CONTENT_SLIDER,
])
->setReference( 'vacancy_components'),
]);
}
}