File: D:/HostingSpaces/SBogers10/beat-the-barn.komma.nl/app/Posts/Kms/PostSection.php
<?php
namespace App\Posts\Kms;
use App\Authors\Models\Author;
use App\Components\ComponentTypes;
use Illuminate\Database\Eloquent\Model;
use Komma\KMS\Core\Attributes\ComponentArea;
use Komma\KMS\Core\Attributes\DatePicker;
use Komma\KMS\Core\Attributes\Documents;
use Komma\KMS\Core\Attributes\Models\ImageProperty;
use Komma\KMS\Core\Attributes\OnOff;
use Komma\KMS\Core\Attributes\Select;
use Komma\KMS\Core\Attributes\Seperator;
use Komma\KMS\Core\Attributes\TextArea;
use Komma\KMS\Core\Attributes\TextField;
use Komma\KMS\Core\ModelServiceInterface;
use Komma\KMS\Core\Sections\Section;
final class PostSection extends Section
{
/**
* Define the attributes and tabs for this section.
*
* @param Model $currentModel
*/
public function defineAttributesAndTabs(Model $currentModel = null): void
{
/** @var ModelServiceInterface $authorService */
$authorService = app()->make(ModelServiceInterface::class);
$authorService->setModelClassName(Author::class);
$this->tabs->makeTab()->addItems([
(new OnOff())
->setReference('active')
->setLabelText(__('KMS::global.active'))
->switchOn(),
(new Select())
->setReference('author_id')
->setItems($authorService->getOptionsForSelect(true)->toArray())
->setLabelText('Auteur'),
(new DatePicker())
->setReference('date')
->setLabelText(__('KMS::global.date'))
->setTimeEnabled(false),
(new Documents())
->setReference('posts')
->setLabelText(__('KMS::global.index_image'))
->onlyAllowImages()
->setSmallDragAndDropArea()
->setMaxDocuments(1)
->setImageProperties([
(new ImageProperty())->setName('large')->setCropMethod(ImageProperty::Resize)->setWidth(2400),
(new ImageProperty())->setName('medium')->setCropMethod(ImageProperty::Resize)->setWidth(1480),
(new ImageProperty())->setName('small')->setCropMethod(ImageProperty::Fit)->setWidth(444)->setHeight(336),
])
->setSubFolder('posts'),
]);
$this->tabs->makeLanguageTabTemplate()->addItems([
(new TextField())
->setReference('name')
->setLabelText(__('KMS::global.title')),
(new TextArea())
->setReference('description')
->setLabelText(__('KMS::global.shortDescription')),
(new Seperator()),
(new TextField())
->setReference('meta_title')
->setLabelText(__('KMS::global.metaTitle')),
(new TextArea())
->setReference('meta_description')
->setLabelText(__('KMS::global.metaDescription')),
(new ComponentArea())
->setReference('post_components')
->setSubFolder('post_component_data')
->setComponentTypes([
ComponentTypes::TEXT,
ComponentTypes::IMAGE,
ComponentTypes::VIDEO,
]),
]);
}
}