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/vebon.komma.pro/app/KommaApp/Languages/Kms/LanguageRepository.php
<?php

namespace KommaApp\Languages\Kms;

/**
 *
 * @author      Komma <info@komma.pro>
 * @copyright   (c) 2012-2016, Komma Mediadesign
 */


use KommaApp\Kms\Core\Entities\EntityRepository;

class LanguageRepository extends EntityRepository
{
    /**
     * The Eloquent User Object.
     *
     * @var Language
     */
    public $model;

    /**
     * Constructor.
     *
     * @param Language $model
     */
    function __construct(Language $model)
    {
        $this->model = $model;
    }

    public function find($id)
    {
        return $this->model->find($id);
    }

    public function findBySlug($slug)
    {
        return $this->model->whereSlug($slug)->first();
    }

    public function findAll()
    {
        return $this->model->all();
    }

    public function getLanguagesForSelect()
    {
        $models = $this->model->with('sites')->get();
        $entities = [];
        foreach($models as $model)
        {
            if(count($model->sites) == 0) continue;
            $entity = [];
            $entity['value'] = $model->id;
            $entity['fullValue'] = json_encode($model);
            $entity['content'] = $model->name;
            $entities[] = $entity;
        }
        return $entities;
    }
}