42 lines
1.2 KiB
PHP
42 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Pterodactyl\Repositories\Eloquent;
|
|
|
|
use Pterodactyl\Models\Server;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
|
use Pterodactyl\Exceptions\Repository\RecordNotFoundException;
|
|
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
|
|
|
|
class ServerRepository extends EloquentRepository implements ServerRepositoryInterface
|
|
{
|
|
/**
|
|
* Return the model backing this repository.
|
|
*/
|
|
public function model(): string
|
|
{
|
|
return Server::class;
|
|
}
|
|
|
|
/**
|
|
* Return a server by UUID.
|
|
*
|
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
|
*/
|
|
public function getByUuid(string $uuid): Server
|
|
{
|
|
try {
|
|
/** @var \Pterodactyl\Models\Server $model */
|
|
$model = $this->getBuilder()
|
|
->with('nest', 'node')
|
|
->where(function (Builder $query) use ($uuid) {
|
|
$query->where('uuidShort', $uuid)->orWhere('uuid', $uuid);
|
|
})
|
|
->firstOrFail($this->getColumns());
|
|
|
|
return $model;
|
|
} catch (ModelNotFoundException) {
|
|
throw new RecordNotFoundException();
|
|
}
|
|
}
|
|
}
|