File: D:/HostingSpaces/ASmits/kemi.nl/app/KommaApp/Machines/Kms/MachineService.php
<?php
namespace App\KommaApp\Machines\Kms;
use App\Helpers\KommaHelpers;
use App\KommaApp\Kms\Core\Attributes\Attribute;
use App\KommaApp\Kms\Core\NestedSets\Nodes\EloquentNode;
use App\KommaApp\Kms\Core\Sections\SectionService;
use App\KommaApp\Kms\Core\Sections\SectionTabItem;
use App\KommaApp\Kms\SidebarListItem;
use App\KommaApp\Languages\Models\Language;
use App\KommaApp\Pages\Models\PageTranslation;
use App\KommaApp\Machines\Models\Machine;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
class MachineService extends SectionService
{
protected $sortable = false;
protected $orderBy = 'name';
protected $orderReverse = false;
function __construct()
{
$this->forModelName = Machine::class;
parent::__construct();
}
/**
* Returns all models for the sidebar menu in the backend
*
* @return array
*/
public function getModelsForSideBar():array
{
$models = Machine::with('translation')
->get();
$sidebarList = [];
foreach ($models as $model) {
$sidebarListItem = new SidebarListItem();
$this->setThumbnail($model);
$this->generateThumbnail($model);
//Set the values for the sidebar
$sidebarListItem->setId($model->id);
$sidebarListItem->setStatus($model->active);
$title = KommaHelpers::str_limit_full_word($model->translation->name, 75);
$sidebarListItem->setName($title);
$sidebarListItem->setThumbnail($model->thumbnail);
$sidebarList[$title . '-' . $model->id] = $sidebarListItem;
}
ksort($sidebarList);
return $sidebarList;
}
}