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

53 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
2019-09-06 04:32:57 +00:00
* @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')
->paginate(50, $this->getColumns());
}
}