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/SBogers10/reiskick.komma.nl/app/Countries/Kms/CountrySection.php
<?php

namespace App\Countries\Kms;

use App\Components\ComponentTypes;
use App\Countries\Country;
use App\Pages\Models\Page;
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\Link;
use Komma\KMS\Core\Attributes\Models\ImageProperty;
use Komma\KMS\Core\Attributes\Models\SelectOption;
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;
use Komma\KMS\Users\Models\KmsUserRole;

final class CountrySection extends Section
{

    /**
     * Define the attributes and tabs for this section.
     *
     * @param Model $currentModel
     */
    public function defineAttributesAndTabs(Model $currentModel = null): void
    {
        /** @var ModelServiceInterface $pageModelService */
        $countryModelService = app()->make(CountryModelService::class);

        $countryPageRoute = Page::where('code_name', 'countries')
            ->with('translation', 'translation.route')
            ->has('translation')
            ->has('translation.route')
            ->first();

        if($currentModel != null && $countryPageRoute != null) $countryRoute = $countryPageRoute->translation->route->alias . '/' . $currentModel->slug;
        else $countryRoute = '';

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

            (new OnOff())
                ->setReference('active')
                ->setLabelText(__('KMS::global.active'))
                ->switchOn()
                ->setExplanation('Inactive landen hebben geen overzicht pagina.'),

            (new Select())
                ->setItems($countryModelService->getOptionsForSelectAsTree()->toArray())
                ->setLabelText(__('KMS::pages.parent_page'))
                ->enableExcludeCurrentModelItem()
                ->setMinimumUserRole(KmsUserRole::SuperAdmin)
                ->mapValueFrom(Attribute::ValueFromItself, 'parent_id'),

            (new TextField())
                ->setReference('name')
                ->setLabelText(__('KMS::global.title'))
                ->setExplanation('Om Alpha-2 op te zoeken; https://www.iso.org/obp/ui/#search'),

            (new Select())
                ->setReference('map_iso')
                ->setItems($countryModelService->getWorldMapIsoOptions()->toArray())
                ->setLabelText("Map Alpha-2 bv: NL, FR"),

            (new Select())
                ->setItems($countryModelService->getContinentsForSelect()->toArray())
                ->setLabelText('Continent')
                ->setReference('continent'),

            (new Link())
                ->setLabelText('Url')
                ->setLinkText($countryRoute)
                ->setLink($countryRoute),

            (new Seperator()),

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

            (new Select())
                ->setItems($countryModelService->getHomePositionsForSelect()->toArray())
                ->setLabelText('Grid positie')
                ->setReference('home_grid_position'),

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

            (new Seperator()),

            (new Title())->setLabelText('Detail pagina'),

            (new Documents())
                ->setReference('heading')
                ->setLabelText('Hoofdfoto')
                ->onlyAllowImages()
                ->setSmallDragAndDropArea()
                ->setSubFolder('country_heading')
                ->setMaxDocuments(1)
                ->setImageProperties([
                    (new ImageProperty())->setName('large')->setCropMethod(ImageProperty::Resize)->setWidth(2200),
                    (new ImageProperty())->setName('medium')->setCropMethod(ImageProperty::Resize)->setWidth(1240),
                    (new ImageProperty())->setName('small')->setCropMethod(ImageProperty::Resize)->setWidth(800),
                ]),


        ]);
    }
}