File: D:/HostingSpaces/SBogers10/base.komma.pro/app/TeamMembers/Kms/TeamMemberSection.php
<?php
namespace App\TeamMembers\Kms;
use App\TeamMembers\Models\TeamMember;
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 TeamMemberSection extends Section
{
public function defineAttributesAndTabs(Model $currentModel = null): void
{
/** @var ModelServiceInterface $teamMemberModelService */
$teamMemberModelService = app(ModelServiceInterface::class);
$teamMemberModelService->setModelClassName(TeamMember::class);
$this->tabs->makeTab()->addItems([
(new OnOff())
->setReference('active')
->setLabelText(__('KMS::global.active'))
->switchOn(),
(new Documents())
->setReference('teamMembers')
->setLabelText(__('KMS::global.images'))
->onlyAllowImages()
->setSmallDragAndDropArea()
->setMaxDocuments(1)
->setSubFolder('teamMembers')
->setImageProperties([
(new ImageProperty())->setName('thumb')->setCropMethod(ImageProperty::Fit)->setWidth(100)->setHeight(100),
(new ImageProperty())->setName('small')->setCropMethod(ImageProperty::Fit)->setWidth(200)->setHeight(200),
(new ImageProperty())->setName('medium')->setCropMethod(ImageProperty::Fit)->setWidth(300)->setHeight(300),
]),
(new TextField())
->setReference('name')
->setLabelText(__('KMS::global.name')),
(new TextField())
->setReference('email')
->setLabelText(__('KMS::global.email')),
(new Select())
->setItems($teamMemberModelService->getOptionsForSelectAsTree()->toArray())
->setLabelText(__('KMS::team_members.parent_team_member'))
->enableExcludeCurrentModelItem()
->setStyleClass('hidden')
->mapValueFrom(Attribute::ValueFromItself, 'parent_id')
]);
$this->tabs->makeLanguageTabTemplate()->addItems([
(new TextField())
->setReference('function')
->setLabelText(__('KMS::global.function')),
]);
}
}