getBuilder()->withCount('eggs', 'nodes')->get($this->getColumns()); } /** * Return all of the mounts and their respective relations. * * @param string $id * @return mixed * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ public function getWithRelations(string $id): Mount { try { return $this->getBuilder()->with('eggs', 'nodes')->findOrFail($id, $this->getColumns()); } catch (ModelNotFoundException $exception) { throw new RecordNotFoundException; } } /** * Return mounts available to a server. (ignoring if they are or are not mounted) * * @param Server $server * @return \Illuminate\Support\Collection */ public function getMountListForServer(Server $server): Collection { return $this->getBuilder() ->whereHas('eggs', function ($q) use ($server) { $q->where('id', '=', $server->egg_id); }) ->whereHas('nodes', function ($q) use ($server) { $q->where('id', '=', $server->node_id); }) ->get($this->getColumns()); } }