paginate databases when viewing a host
This commit is contained in:
parent
e8cb441fc8
commit
c739f292e4
7 changed files with 47 additions and 50 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue