Skip to content

Commit 86b7b6e

Browse files
committed
Add Models/ServerTransfer.php
1 parent 5007ce0 commit 86b7b6e

File tree

2 files changed

+122
-0
lines changed

2 files changed

+122
-0
lines changed

app/Models/ServerTransfer.php

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
3+
namespace Pterodactyl\Models;
4+
5+
/**
6+
* @property int $id
7+
* @property int $server_id
8+
* @property int $old_node
9+
* @property int $new_node
10+
* @property int $old_allocation
11+
* @property int $new_allocation
12+
* @property string $old_additional_allocations
13+
* @property string $new_additional_allocations
14+
* @property \Carbon\Carbon $created_at
15+
* @property \Carbon\Carbon $updated_at
16+
*
17+
* @property \Pterodactyl\Models\Server $server
18+
*/
19+
class ServerTransfer extends Validable
20+
{
21+
/**
22+
* The resource name for this model when it is transformed into an
23+
* API representation using fractal.
24+
*/
25+
const RESOURCE_NAME = 'server_transfer';
26+
27+
/**
28+
* The table associated with the model.
29+
*
30+
* @var string
31+
*/
32+
protected $table = 'server_transfers';
33+
34+
/**
35+
* Fields that are not mass assignable.
36+
*
37+
* @var array
38+
*/
39+
protected $guarded = ['id', 'created_at', 'updated_at'];
40+
41+
/**
42+
* Cast values to correct type.
43+
*
44+
* @var array
45+
*/
46+
protected $casts = [
47+
'server_id' => 'int',
48+
'old_node' => 'int',
49+
'new_node' => 'int',
50+
'old_allocation' => 'int',
51+
'new_allocation' => 'int',
52+
'old_additional_allocations' => 'string',
53+
'new_additional_allocations' => 'string',
54+
];
55+
56+
/**
57+
* @var array
58+
*/
59+
public static $validationRules = [
60+
'server_id' => 'required|numeric|exists:servers,id',
61+
'old_node' => 'required|numeric',
62+
'new_node' => 'required|numeric',
63+
'old_allocation' => 'required|numeric',
64+
'new_allocation' => 'required|numeric',
65+
'old_additional_allocations' => 'nullable',
66+
'new_additional_allocations' => 'nullable',
67+
];
68+
69+
/**
70+
* Gets the server associated with a subuser.
71+
*
72+
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
73+
*/
74+
public function server()
75+
{
76+
return $this->belongsTo(Server::class);
77+
}
78+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
use Illuminate\Support\Facades\Schema;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Database\Migrations\Migration;
6+
7+
class AddTableServerTransfers extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::dropIfExists('server_transfers');
17+
18+
Schema::create('server_transfers', function (Blueprint $table) {
19+
$table->increments('id');
20+
$table->integer('server_id')->unsigned();
21+
$table->integer('old_node')->unsigned();
22+
$table->integer('new_node')->unsigned();
23+
$table->integer('old_allocation')->unsigned();
24+
$table->integer('new_allocation')->unsigned();
25+
$table->string('old_additional_allocations')->nullable();
26+
$table->string('new_additional_allocations')->nullable();
27+
$table->timestamps();
28+
});
29+
30+
Schema::table('server_transfers', function (Blueprint $table) {
31+
$table->foreign('server_id')->references('id')->on('servers');
32+
});
33+
}
34+
35+
/**
36+
* Reverse the migrations.
37+
*
38+
* @return void
39+
*/
40+
public function down()
41+
{
42+
Schema::dropIfExists('server_transfers');
43+
}
44+
}

0 commit comments

Comments
 (0)