File: D:/HostingSpaces/SBogers10/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, $excludeId = null, $allowNull = true)
{
$entities = [];
$sites = Site::all();
foreach($sites as $site){
$entities[] = (new SelectOption())
->setValue($site->id)
->setContent($site->id)
->setHtmlContent($site->name);
}
return $entities;
}
}