HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/Neopoints/momsecurity.be/app/Posts/Kms/PostSection.php
<?php

namespace App\Posts\Kms;

use App\Authors\Models\Author;
use App\Components\ComponentTypes;
use App\PostLabels\Models\PostLabel;
use Illuminate\Database\Eloquent\Model;
use Komma\KMS\Core\Attributes\Attribute;
use Komma\KMS\Core\Attributes\ComponentArea;
use Komma\KMS\Core\Attributes\DatePicker;
use Komma\KMS\Core\Attributes\Documents;
use Komma\KMS\Core\Attributes\MultiSelect;
use Komma\KMS\Core\Attributes\Numeric;
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\Attributes\Title;
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 $postLabelService */
        $postLabelService = app(ModelServiceInterface::class);
        $postLabelService->setModelClassName(PostLabel::class);

        $this->tabs->makeTab()->addItems([

            (new OnOff())
                ->setReference('active')
                ->setLabelText(__('KMS::global.active'))
                ->switchOn(),

            (new DatePicker())
                ->setReference('date')
                ->setLabelText(__('KMS::global.date'))
                ->setTimeEnabled(false),

            (new Documents())
                ->setReference('posts')
                ->setLabelText(__('KMS::global.index_image'))
                ->onlyAllowImages()
                ->setSmallDragAndDropArea()
                ->setMaxDocuments(1)
                ->setSubFolder('posts'),

            (new MultiSelect())
                ->setLabelText('Tags / Labels')
                ->setItems($postLabelService->getOptionsForSelect()->toArray())
                ->mapValueFrom(Attribute::ValueFromModelHasManyRelation, 'labels|id'),
        ]);

        $this->tabs->makeLanguageTabTemplate()->addItems([
            (new TextField())
                ->setReference('name')
                ->setLabelText(__('KMS::global.title')),

            (new TextArea())
                ->setLabelText('Teaser')
                ->setReference('teaser')
                ->setExplanation('Voor overzicht pagina'),

            (new Seperator()),

            (new Title())->setLabelText('SEO'),

            (new TextField())
                ->setReference('meta_title')
                ->setLabelText(__('KMS::global.metaTitle')),

            (new TextArea())
                ->setLabelText(__('KMS::global.metaDescription'))
                ->setReference('meta_description'),

            (new ComponentArea())
                ->setReference('post_components')
                ->setSubFolder('post_component_data')
                ->setComponentTypes(ComponentTypes::getPostComponents()),
        ]);
    }
}