misc_pterodactyl-panel/app/Repositories/Eloquent/PackRepository.php

54 lines
1.4 KiB
PHP
Raw Normal View History

<?php
namespace Pterodactyl\Repositories\Eloquent;
use Pterodactyl\Models\Pack;
use Pterodactyl\Repositories\Concerns\Searchable;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
use Pterodactyl\Contracts\Repository\PackRepositoryInterface;
2017-07-15 16:52:34 +00:00
class PackRepository extends EloquentRepository implements PackRepositoryInterface
{
use Searchable;
/**
* Return the model backing this repository.
*
* @return string
2017-07-15 16:52:34 +00:00
*/
public function model()
{
return Pack::class;
}
2017-07-15 16:52:34 +00:00
/**
* Return a pack with the associated server models attached to it.
*
* @param \Pterodactyl\Models\Pack $pack
* @param bool $refresh
* @return \Pterodactyl\Models\Pack
*/
public function loadServerData(Pack $pack, bool $refresh = false): Pack
2017-07-15 16:52:34 +00:00
{
if ($refresh) {
$pack->load(['servers.node', 'servers.user']);
}
$pack->loadMissing(['servers.node', 'servers.user']);
return $pack;
}
/**
* Return a paginated listing of packs with their associated egg and server count.
*
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
*/
public function paginateWithEggAndServerCount(): LengthAwarePaginator
{
return $this->getBuilder()->with('egg')->withCount('servers')
2018-01-06 18:49:32 +00:00
->search($this->getSearchTerm())
->paginate(50, $this->getColumns());
}
}