diff --git a/app/Http/Controllers/Admin/ServersController.php b/app/Http/Controllers/Admin/ServersController.php index 6f8e106ef..864423cf9 100644 --- a/app/Http/Controllers/Admin/ServersController.php +++ b/app/Http/Controllers/Admin/ServersController.php @@ -263,7 +263,7 @@ class ServersController extends Controller $this->buildModificationService->handle($server, $request->only([ 'allocation_id', 'add_allocations', 'remove_allocations', 'memory', 'swap', 'io', 'cpu', 'threads', 'disk', - 'database_limit', 'allocation_limit', 'oom_disabled', + 'database_limit', 'allocation_limit', 'backup_limit', 'oom_disabled', ])); $this->alert->success(trans('admin/server.alerts.build_updated'))->flash(); diff --git a/app/Models/Server.php b/app/Models/Server.php index 97fea38a8..5a5ace99e 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -2,7 +2,6 @@ namespace Pterodactyl\Models; -use Schema; use Illuminate\Notifications\Notifiable; use Pterodactyl\Models\Traits\Searchable; use Znck\Eloquent\Traits\BelongsToThrough; @@ -34,6 +33,7 @@ use Znck\Eloquent\Traits\BelongsToThrough; * @property int $installed * @property int $allocation_limit * @property int $database_limit + * @property int $backup_limit * @property \Carbon\Carbon $created_at * @property \Carbon\Carbon $updated_at * @@ -127,6 +127,7 @@ class Server extends Model 'installed' => 'in:0,1,2', 'database_limit' => 'present|nullable|integer|min:0', 'allocation_limit' => 'sometimes|nullable|integer|min:0', + 'backup_limit' => 'present|nullable|integer|min:0', ]; /** @@ -152,6 +153,7 @@ class Server extends Model 'installed' => 'integer', 'database_limit' => 'integer', 'allocation_limit' => 'integer', + 'backup_limit' => 'integer', ]; /** @@ -170,16 +172,6 @@ class Server extends Model 'pack.name' => 10, ]; - /** - * Return the columns available for this table. - * - * @return array - */ - public function getTableColumns() - { - return Schema::getColumnListing($this->getTable()); - } - /** * Returns the format for server allocations when communicating with the Daemon. * diff --git a/app/Services/Servers/BuildModificationService.php b/app/Services/Servers/BuildModificationService.php index 0a010b545..5f4b10d34 100644 --- a/app/Services/Servers/BuildModificationService.php +++ b/app/Services/Servers/BuildModificationService.php @@ -101,8 +101,9 @@ class BuildModificationService 'threads' => array_get($data, 'threads'), 'disk' => array_get($data, 'disk'), 'allocation_id' => array_get($data, 'allocation_id'), - 'database_limit' => array_get($data, 'database_limit'), - 'allocation_limit' => array_get($data, 'allocation_limit'), + 'database_limit' => array_get($data, 'database_limit', 0), + 'allocation_limit' => array_get($data, 'allocation_limit', 0), + 'backup_limit' => array_get($data, 'backup_limit', 0), ]); $updateData = $this->structureService->handle($server); diff --git a/app/Services/Servers/ServerCreationService.php b/app/Services/Servers/ServerCreationService.php index cf0900282..cce242e5a 100644 --- a/app/Services/Servers/ServerCreationService.php +++ b/app/Services/Servers/ServerCreationService.php @@ -249,8 +249,9 @@ class ServerCreationService 'pack_id' => empty($data['pack_id']) ? null : $data['pack_id'], 'startup' => Arr::get($data, 'startup'), 'image' => Arr::get($data, 'image'), - 'database_limit' => Arr::get($data, 'database_limit'), - 'allocation_limit' => Arr::get($data, 'allocation_limit'), + 'database_limit' => Arr::get($data, 'database_limit', 0), + 'allocation_limit' => Arr::get($data, 'allocation_limit', 0), + 'backup_limit' => Arr::get($data, 'backup_limit', 0), ]); return $model; diff --git a/app/Transformers/Api/Application/ServerTransformer.php b/app/Transformers/Api/Application/ServerTransformer.php index 4fb31212d..d9df4263a 100644 --- a/app/Transformers/Api/Application/ServerTransformer.php +++ b/app/Transformers/Api/Application/ServerTransformer.php @@ -80,6 +80,7 @@ class ServerTransformer extends BaseTransformer 'feature_limits' => [ 'databases' => $server->database_limit, 'allocations' => $server->allocation_limit, + 'backups' => $server->backup_limit, ], 'user' => $server->owner_id, 'node' => $server->node_id, diff --git a/app/Transformers/Api/Client/ServerTransformer.php b/app/Transformers/Api/Client/ServerTransformer.php index 2878f92f0..50d45e276 100644 --- a/app/Transformers/Api/Client/ServerTransformer.php +++ b/app/Transformers/Api/Client/ServerTransformer.php @@ -55,6 +55,7 @@ class ServerTransformer extends BaseClientTransformer 'feature_limits' => [ 'databases' => $server->database_limit, 'allocations' => $server->allocation_limit, + 'backups' => $server->backup_limit, ], 'is_suspended' => $server->suspended !== 0, 'is_installing' => $server->installed !== 1, diff --git a/database/migrations/2020_04_26_111208_add_backup_limit_to_servers.php b/database/migrations/2020_04_26_111208_add_backup_limit_to_servers.php new file mode 100644 index 000000000..c9be6c954 --- /dev/null +++ b/database/migrations/2020_04_26_111208_add_backup_limit_to_servers.php @@ -0,0 +1,32 @@ +unsignedInteger('backup_limit')->default(0)->after('database_limit'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('servers', function (Blueprint $table) { + $table->dropColumn('backup_limit'); + }); + } +} diff --git a/resources/scripts/api/server/getServer.ts b/resources/scripts/api/server/getServer.ts index 62cf61b78..0a0b4e4a5 100644 --- a/resources/scripts/api/server/getServer.ts +++ b/resources/scripts/api/server/getServer.ts @@ -29,6 +29,7 @@ export interface Server { featureLimits: { databases: number; allocations: number; + backups: number; }; isSuspended: boolean; isInstalling: boolean; diff --git a/resources/views/admin/servers/new.blade.php b/resources/views/admin/servers/new.blade.php index 1d61f1a50..e69310d7d 100644 --- a/resources/views/admin/servers/new.blade.php +++ b/resources/views/admin/servers/new.blade.php @@ -118,15 +118,21 @@
The total number of databases a user is allowed to create for this server. Leave blank to allow unlimited.
+The total number of databases a user is allowed to create for this server.
-The total number of allocations a user is allowed to create for this server. Leave blank to allow unlimited.
+The total number of allocations a user is allowed to create for this server.
+The total number of backups that can be created for this server.
The total number of databases a user is allowed to create for this server. Leave blank to allow unlimited.
+The total number of databases a user is allowed to create for this server.
This feature is not currently implemented. The total number of allocations a user is allowed to create for this server. Leave blank to allow unlimited.
+This feature is not currently implemented. The total number of allocations a user is allowed to create for this server.
+The total number of backups that can be created for this server.