forked from pterodactyl/panel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDatabaseHostRepository.php
More file actions
51 lines (46 loc) · 1.47 KB
/
Copy pathDatabaseHostRepository.php
File metadata and controls
51 lines (46 loc) · 1.47 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
<?php
namespace Pterodactyl\Repositories\Eloquent;
use Illuminate\Support\Collection;
use Pterodactyl\Models\DatabaseHost;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Pterodactyl\Exceptions\Repository\RecordNotFoundException;
use Pterodactyl\Contracts\Repository\DatabaseHostRepositoryInterface;
class DatabaseHostRepository extends EloquentRepository implements DatabaseHostRepositoryInterface
{
/**
* Return the model backing this repository.
*
* @return string
*/
public function model()
{
return DatabaseHost::class;
}
/**
* Return database hosts with a count of databases and the node
* information for which it is attached.
*
* @return \Illuminate\Support\Collection
*/
public function getWithViewDetails(): Collection
{
return $this->getBuilder()->withCount('databases')->with('node')->get();
}
/**
* Return a database host with the databases and associated servers
* that are attached to said databases.
*
* @param int $id
* @return \Pterodactyl\Models\DatabaseHost
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function getWithServers(int $id): DatabaseHost
{
try {
return $this->getBuilder()->with('databases.server')->findOrFail($id, $this->getColumns());
} catch (ModelNotFoundException $exception) {
throw new RecordNotFoundException;
}
}
}