File: D:/HostingSpaces/SBogers85/equichecker.com/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;
}
}