diff --git a/app/Models/ServerTransfer.php b/app/Models/ServerTransfer.php new file mode 100644 index 000000000..15000043f --- /dev/null +++ b/app/Models/ServerTransfer.php @@ -0,0 +1,78 @@ + 'int', + 'old_node' => 'int', + 'new_node' => 'int', + 'old_allocation' => 'int', + 'new_allocation' => 'int', + 'old_additional_allocations' => 'string', + 'new_additional_allocations' => 'string', + ]; + + /** + * @var array + */ + public static $validationRules = [ + 'server_id' => 'required|numeric|exists:servers,id', + 'old_node' => 'required|numeric', + 'new_node' => 'required|numeric', + 'old_allocation' => 'required|numeric', + 'new_allocation' => 'required|numeric', + 'old_additional_allocations' => 'nullable', + 'new_additional_allocations' => 'nullable', + ]; + + /** + * Gets the server associated with a subuser. + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ + public function server() + { + return $this->belongsTo(Server::class); + } +} diff --git a/database/migrations/2020_04_04_131016_add_table_server_transfers.php b/database/migrations/2020_04_04_131016_add_table_server_transfers.php new file mode 100644 index 000000000..1ce37c26d --- /dev/null +++ b/database/migrations/2020_04_04_131016_add_table_server_transfers.php @@ -0,0 +1,44 @@ +increments('id'); + $table->integer('server_id')->unsigned(); + $table->integer('old_node')->unsigned(); + $table->integer('new_node')->unsigned(); + $table->integer('old_allocation')->unsigned(); + $table->integer('new_allocation')->unsigned(); + $table->string('old_additional_allocations')->nullable(); + $table->string('new_additional_allocations')->nullable(); + $table->timestamps(); + }); + + Schema::table('server_transfers', function (Blueprint $table) { + $table->foreign('server_id')->references('id')->on('servers'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('server_transfers'); + } +}