File: D:/HostingSpaces/SBogers10/beat-the-barn.komma.nl/app/Projects/Kms/ProjectSection.php
<?php
namespace App\Projects\Kms;
use App\Buttons\Kms\ButtonService;
use App\Categories\CategoryService;
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\Numeric;
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 Komma\KMS\Users\Models\KmsUserRole;
final class ProjectSection extends Section
{
public function defineAttributesAndTabs(Model $currentModel = null): void
{
$categoryService = new CategoryService();
$categoryOptions = $categoryService->getOptionsForSelect();
/** @var ServicepointService $servicePointService */
$servicePointService = \App::make(ServicepointService::class);
$servicePointOptions = $servicePointService->getOptionsForSelect(false);
/** @var ButtonService $buttonsService */
$buttonsService = \App::make(ButtonService::class);
$buttonModels = $buttonsService->getOptionsForSelect();
$this->tabs->makeTab()->addItems([
(new OnOff())
->setReference('active')
->setLabelText(__('KMS::global.active'))
->switchOn(),
(new Documents())
->setReference('projects')
->setLabelText(__('KMS::global.index_image'))
->onlyAllowImages()
->setSmallDragAndDropArea()
->setMaxDocuments(1)
->setSubFolder('projects')
->setImageProperties([
(new ImageProperty())->setName('small')->setCropMethod(ImageProperty::Fit)->setWidth(326)->setHeight(200),
(new ImageProperty())->setName('medium')->setCropMethod(ImageProperty::Fit)->setWidth(384)->setHeight(336),
(new ImageProperty())->setName('large')->setCropMethod(ImageProperty::Fit)->setWidth(540)->setHeight(414),
]),
(new MultiSelect())
->mapValueFrom(Attribute::ValueFromModelHasManyRelation, 'categories|id')
->setItems($categoryOptions->toArray())
->setLabelText('Categorie voor filter')
->setMinimumUserRole(KmsUserRole::Admin),
(new Seperator()),
(new Title())
->setLabelText('Prijs'),
(new Numeric())
->setReference('price')
->setPrefix('€')
->setFractionLength(2)
->setFractionMax(99)
->setFractionZeroPadding()
->setSuffix('p.p.'),
(new OnOff())
->setReference('with_drinks')
->setLabelText('Met drank')
->switchOn(),
(new Seperator()),
(new Title())
->setLabelText('Extra options'),
(new OnOff())
->setReference('catering')
->setLabelText('Catering')
->switchOn(),
(new OnOff())
->setReference('office')
->setLabelText('Vergaderruimte')
->switchOn(),
(new OnOff())
->setReference('overnight')
->setLabelText('Overnachtingen')
->switchOn(),
(new OnOff())
->setReference('for_children')
->setLabelText('Voor kinderen')
->switchOn(),
(new Seperator())
->setMinimumUserRole(KmsUserRole::SuperAdmin),
(new Title())
->setLabelText(__('KMS::global.servicePoint'))
->setMinimumUserRole(KmsUserRole::SuperAdmin),
// (new TextField())
// ->setReference('servicepoint_heading')
// ->setLabelText(__('KMS::global.servicePoint'))
// ->setMinimumUserRole(KmsUserRole::SuperAdmin),
(new MultiSelect())
->setReference('servicepoint_id')
->setItems($servicePointOptions->toArray())
->setLabelText('Contactpersoon')
->setMaxItemsToSelect(1)
->setMinimumUserRole(KmsUserRole::SuperAdmin),
// (new MultiSelect())
// ->setReference('servicepoint_button_id')
// ->setItems($buttonModels->toArray())
// ->setLabelText('Knop')
// ->setMinimumUserRole(KmsUserRole::SuperAdmin)
// ->setMaxItemsToSelect(1),
]);
$this->tabs->makeLanguageTabTemplate()->addItems([
(new TextField())
->setReference('name')
->setLabelText(__('KMS::global.title')),
(new TextArea())
->setReference('list')
->setLabelText('Lijst'),
(new TextArea())
->setReference('description')
->enableTinymceEditor()
->setLabelText(__('KMS::global.description')),
(new Seperator())
->setMinimumUserRole(KmsUserRole::Admin),
(new Title())
->setLabelText('Meta gegevens')
->setMinimumUserRole(KmsUserRole::Admin),
(new TextField())
->setReference('meta_title')
->setLabelText(__('KMS::global.metaTitle'))
->setMinimumUserRole(KmsUserRole::Admin),
(new TextArea())
->setReference('meta_description')
->setLabelText(__('KMS::global.metaDescription'))
->setMinimumUserRole(KmsUserRole::Admin),
// (new ComponentArea())
// ->setReference('project_components')
// ->setSubFolder('project_component_data')
// ->setComponentTypes([
// ComponentTypes::TEXT,
// ComponentTypes::IMAGE,
// ComponentTypes::TEXT_IMAGE,
// ComponentTypes::VIDEO,
// ComponentTypes::QUOTE,
// ComponentTypes::FEATURED_SERVICES,
// ComponentTypes::TESTIMONIALS,
// ComponentTypes::TEXT_IMAGE_BOX,
// ComponentTypes::TEASER,
// ComponentTypes::CARDS,
// ])
]);
}
}