forked from pterodactyl/panel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPackRepository.php
More file actions
53 lines (45 loc) · 1.41 KB
/
Copy pathPackRepository.php
File metadata and controls
53 lines (45 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
namespace Pterodactyl\Repositories\Eloquent;
use Pterodactyl\Models\Pack;
use Pterodactyl\Repositories\Concerns\Searchable;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
use Pterodactyl\Contracts\Repository\PackRepositoryInterface;
class PackRepository extends EloquentRepository implements PackRepositoryInterface
{
use Searchable;
/**
* Return the model backing this repository.
*
* @return string
*/
public function model()
{
return Pack::class;
}
/**
* 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
{
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')
->search($this->getSearchTerm())
->paginate(50, $this->getColumns());
}
}