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/shop.komma.nl/app/Properties/Kms/PropertyKeySection.php
<?php
namespace App\Properties\Kms;

use Illuminate\Database\Eloquent\Model;
use Komma\KMS\Core\Attributes\Attribute;
use Komma\KMS\Core\Attributes\TextField;
use Komma\KMS\Core\Sections\Section;
use Komma\KMS\Globalization\Languages\Models\Language;
use Komma\KMS\Sites\Kms\SiteService;

class PropertyKeySection extends Section
{
    /**
     * Define the attributes and tabs for this section.
     *
     * @param Model $currentModel
     */
    public function defineAttributesAndTabs(Model $currentModel = null): void
    {
        $siteService = new SiteService();

        $items = $siteService->languagesHavingSites()->get()->map(function(Language $language) {
            return [
                (new TextField())
                    ->setLabelText(__('KMS::properties.property').' '.$language->iso_2.'')
                    ->setExplanation(__('KMS::properties.key_explanation'))
                    ->setEntity(Attribute::ValueFromItself)
                    ->setReference('key')
                    ->setAssociatedLanguage($language)
            ];
        })->collapse()->toArray();


        $this->tabs->makeTab(__('KMS::properties.properties'))->addItems($items);
    }
}