File: D:/HostingSpaces/SBogers10/reiskick.komma.nl/app/Components/Types/Hotels.php
<?php
namespace App\Components\Types;
use App\Components\ComponentTypes;
use App\Hotels\Kms\HotelService;
use App\Hotels\Models\Hotel;
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 Hotels extends AbstractComponentType
{
protected int $id = ComponentTypes::HOTELS;
protected string $name = 'hotels';
public function defineAttributesAndTabs()
{
/** @var ModelService $selectService */
$selectService = app()->make(HotelService::class);
$selectServiceOptions = $selectService->getComponentSelectOptions();
$this->addItems([
(new TextField())
->setReference('title')
->setLabelText(__('KMS::attributes/components.title')),
(new MultiSelect())
->setReference('options')
->enableSortable()
->setLabelText('Hotels')
->setItems($selectServiceOptions)
->setMaxItemsToSelect(8)
->canBeLinkedWith(Hotel::class),
]);
}
public function prepare(ViewComponent $viewComponent)
{
$viewComponent->options->load('translation', 'images');
}
}