File: D:/HostingSpaces/SBogers10/otium.komma.nl/app/Partners/Kms/PartnerSection.php
<?php
namespace App\Partners\Kms;
use App\Partners\Models\Partner;
use Illuminate\Database\Eloquent\Model;
use Komma\KMS\Core\Attributes\Documents;
use Komma\KMS\Core\Attributes\Attribute;
use Komma\KMS\Core\Attributes\Models\ImageProperty;
use Komma\KMS\Core\Attributes\OnOff;
use Komma\KMS\Core\Attributes\Select;
use Komma\KMS\Core\Attributes\TextField;
use Komma\KMS\Core\ModelServiceInterface;
use Komma\KMS\Core\Sections\Section;
final class PartnerSection extends Section
{
public function defineAttributesAndTabs(Model $currentModel = null): void
{
/** @var ModelServiceInterface $partnerModelService */
$partnerModelService = app(ModelServiceInterface::class);
$partnerModelService->setModelClassName(Partner::class);
$this->tabs->makeTab()->addItems([
(new OnOff())
->setReference('active')
->setLabelText(__('KMS::global.active'))
->switchOn(),
(new Documents())
->setReference('partners')
->setLabelText(__('KMS::global.images'))
->onlyAllowImages()
->setSmallDragAndDropArea()
->setMaxDocuments(1)
->setSubFolder('partners')
->setImageProperties([
(new ImageProperty())->setName('thumb')->setCropMethod(ImageProperty::Resize)->setWidth(100),
(new ImageProperty())->setName('small')->setCropMethod(ImageProperty::Resize)->setWidth(200),
(new ImageProperty())->setName('medium')->setCropMethod(ImageProperty::Resize)->setWidth(300),
]),
(new TextField())
->setReference('name')
->setLabelText(__('KMS::global.name')),
(new TextField())
->setReference('url')
->setLabelText(__('KMS::global.url')),
(new Select())
->mapValueFrom(Attribute::ValueFromItself, 'parent_id')
->setItems($partnerModelService->getOptionsForSelectAsTree()->toArray())
->setLabelText(__('KMS::partners.parent_partner'))
->enableExcludeCurrentModelItem()
->setStyleClass('hidden'),
]);
}
}