Path: blob/1.0-develop/app/Repositories/Eloquent/MountRepository.php
7460 views
<?php12namespace Pterodactyl\Repositories\Eloquent;34use Pterodactyl\Models\Mount;5use Pterodactyl\Models\Server;6use Illuminate\Support\Collection;7use Illuminate\Database\Eloquent\ModelNotFoundException;8use Pterodactyl\Exceptions\Repository\RecordNotFoundException;910class MountRepository extends EloquentRepository11{12/**13* Return the model backing this repository.14*/15public function model(): string16{17return Mount::class;18}1920/**21* Return mounts with a count of eggs, nodes, and servers attached to it.22*/23public function getAllWithDetails(): Collection24{25return $this->getBuilder()->withCount('eggs', 'nodes')->get($this->getColumns());26}2728/**29* Return all the mounts and their respective relations.30*31* @throws RecordNotFoundException32*/33public function getWithRelations(string $id): Mount34{35try {36return $this->getBuilder()->with('eggs', 'nodes')->findOrFail($id, $this->getColumns());37} catch (ModelNotFoundException $exception) {38throw new RecordNotFoundException();39}40}4142/**43* Return mounts available to a server (ignoring if they are or are not mounted).44*/45public function getMountListForServer(Server $server): Collection46{47return $this->getBuilder()48->whereHas('eggs', function ($q) use ($server) {49$q->where('id', '=', $server->egg_id);50})51->whereHas('nodes', function ($q) use ($server) {52$q->where('id', '=', $server->node_id);53})54->get($this->getColumns());55}56}575859