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/Components/Types/MustDos.php
<?php


namespace App\Components\Types;

use App\Buttons\Kms\ButtonService;
use App\Buttons\Models\Button;
use App\Components\ComponentTypes;
use App\MustDos\Kms\MustDoService;
use App\MustDos\Models\MustDo;
use App\Services\Models\Service;
use Illuminate\Support\Facades\App;
use Komma\KMS\Components\Component\ViewComponent;
use Komma\KMS\Components\ComponentType\Types\AbstractComponentType;
use Komma\KMS\Core\Attributes\MultiSelect;
use Komma\KMS\Core\Attributes\TextField;
use Komma\KMS\Core\ModelService;

class MustDos extends AbstractComponentType
{
    protected int $id = ComponentTypes::MUST_DOS;
    protected string $name = 'must-dos';

    public function defineAttributesAndTabs()
    {
        /** @var ModelService $selectService */
        $selectService = app()->make(MustDoService::class);
        $selectServiceOptions = $selectService->getComponentSelectOptions();

        $this->addItems([
            (new TextField())
                ->setReference('title')
                ->setLabelText(__('KMS::attributes/components.title')),

            (new MultiSelect())
                ->setReference('options')
                ->enableSortable()
                ->setLabelText('Must Do\'s')
                ->setItems($selectServiceOptions)
                ->setMaxItemsToSelect(8)
                ->canBeLinkedWith(MustDo::class),
        ]);
    }

    public function prepare(ViewComponent $viewComponent)
    {
        $viewComponent->options->load('translation', 'images');
    }
}