Add mounts page to server admin view

This commit is contained in:
Matthew Penner 2020-05-21 13:19:59 -06:00
parent 34f718a8b1
commit fa902cc074
9 changed files with 151 additions and 17 deletions

View file

@ -4,6 +4,7 @@ namespace Pterodactyl\Repositories\Eloquent;
use Pterodactyl\Models\Mount;
use Illuminate\Support\Collection;
use Pterodactyl\Models\Server;
use Pterodactyl\Repositories\Concerns\Searchable;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Pterodactyl\Exceptions\Repository\RecordNotFoundException;
@ -48,4 +49,22 @@ class MountRepository extends EloquentRepository
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());
}
}