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/lmbm.komma.pro/app/KommaApp/Sites/Kms/SiteService.php
<?php

namespace App\KommaApp\Sites\Kms;

use App\KommaApp\Kms\Core\Attributes\Models\SelectOption;
use App\KommaApp\Kms\Core\Sections\SectionService;
use App\KommaApp\Kms\SidebarListItem;
use App\KommaApp\Sites\Models\Site;

class SiteService extends SectionService
{
    protected $sortable = false;

    function __construct()
    {
        $this->forModelName = Site::class;

        parent::__construct();
    }

    /**
     * This method will get all the models.
     * And add these to the sidebarList.
     *
     * @return array $sidebarList
     */
    public function getModelsForSideBar():array
    {

        $sites = Site::all();

        $sidebarList = [];
        foreach ($sites as $site) {

            //New SidebarListItem
            $sidebarListItem = new SidebarListItem();
            $this->setThumbnail($site);
            $this->generateThumbnail($site);

            //Set the values for the sidebar
            $sidebarListItem->setId($site->id);
            $sidebarListItem->setName($site->name);
            $sidebarListItem->setThumbnail($site->thumbnail);

            $sidebarList[] = $sidebarListItem;
        }

        return $sidebarList;
    }

    /**
     * @param int|null $languageId TODO: Jules. Check if we still need this
     * @param int|null $excludeId TODO: Jules. Check if we still need this
     * @return array
     */
    public function getOptionsForSelect($languageId = null, int $excludeId = null): array
    {
        $entities = [];

        $sites = Site::all();

        foreach($sites as $site){
            $entities[] = (new SelectOption())
                ->setValue($site->id)
                ->setContent($site->id)
                ->setHtmlContent($site->name);
        }
        return $entities;

    }
}