paginate databases when viewing a host

This commit is contained in:
Dane Everitt 2018-03-03 17:52:35 -06:00
parent e8cb441fc8
commit c739f292e4
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
7 changed files with 47 additions and 50 deletions

View file

@ -6,6 +6,7 @@ use Pterodactyl\Models\Database;
use Illuminate\Support\Collection;
use Illuminate\Foundation\Application;
use Illuminate\Database\DatabaseManager;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
use Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface;
use Pterodactyl\Exceptions\Repository\DuplicateDatabaseNameException;
@ -78,6 +79,20 @@ class DatabaseRepository extends EloquentRepository implements DatabaseRepositor
return $this->getBuilder()->where('server_id', $server)->get($this->getColumns());
}
/**
* Return all of the databases for a given host with the server relationship loaded.
*
* @param int $host
* @param int $count
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
*/
public function getDatabasesForHost(int $host, int $count = 25): LengthAwarePaginator
{
return $this->getBuilder()->with('server')
->where('database_host_id', $host)
->paginate($count, $this->getColumns());
}
/**
* Create a new database if it does not already exist on the host with
* the provided details.