Path: blob/1.0-develop/app/Repositories/Eloquent/NestRepository.php
7460 views
<?php12namespace Pterodactyl\Repositories\Eloquent;34use Pterodactyl\Models\Nest;5use Illuminate\Database\Eloquent\Collection;6use Pterodactyl\Contracts\Repository\NestRepositoryInterface;7use Pterodactyl\Exceptions\Repository\RecordNotFoundException;89class NestRepository extends EloquentRepository implements NestRepositoryInterface10{11/**12* Return the model backing this repository.13*/14public function model(): string15{16return Nest::class;17}1819/**20* Return a nest or all nests with their associated eggs and variables.21*22* @throws RecordNotFoundException23*/24public function getWithEggs(?int $id = null): Collection|Nest25{26$instance = $this->getBuilder()->with('eggs', 'eggs.variables');2728if (!is_null($id)) {29$instance = $instance->find($id, $this->getColumns());30if (!$instance) {31throw new RecordNotFoundException();32}3334return $instance;35}3637return $instance->get($this->getColumns());38}3940/**41* Return a nest or all nests and the count of eggs and servers for that nest.42*43* @throws RecordNotFoundException44*/45public function getWithCounts(?int $id = null): Collection|Nest46{47$instance = $this->getBuilder()->withCount(['eggs', 'servers']);4849if (!is_null($id)) {50$instance = $instance->find($id, $this->getColumns());51if (!$instance) {52throw new RecordNotFoundException();53}5455return $instance;56}5758return $instance->get($this->getColumns());59}6061/**62* Return a nest along with its associated eggs and the servers relation on those eggs.63*64* @throws RecordNotFoundException65*/66public function getWithEggServers(int $id): Nest67{68$instance = $this->getBuilder()->with('eggs.servers')->find($id, $this->getColumns());69if (!$instance) {70throw new RecordNotFoundException();71}7273/* @var Nest $instance */74return $instance;75}76}777879