Path: blob/1.0-develop/app/Models/ServerTransfer.php
14039 views
<?php12namespace Pterodactyl\Models;34use Illuminate\Database\Eloquent\Relations\HasOne;5use Illuminate\Database\Eloquent\Relations\BelongsTo;6use Illuminate\Database\Eloquent\Factories\HasFactory;78/**9* @property int $id10* @property int $server_id11* @property int $old_node12* @property int $new_node13* @property int $old_allocation14* @property int $new_allocation15* @property array|null $old_additional_allocations16* @property array|null $new_additional_allocations17* @property bool|null $successful18* @property bool $archived19* @property \Carbon\Carbon $created_at20* @property \Carbon\Carbon $updated_at21* @property Server $server22* @property Node $oldNode23* @property Node $newNode24*/25class ServerTransfer extends Model26{27/** @use HasFactory<\Database\Factories\ServerTransferFactory> */28use HasFactory;2930/**31* The resource name for this model when it is transformed into an32* API representation using fractal.33*/34public const RESOURCE_NAME = 'server_transfer';3536/**37* The table associated with the model.38*/39protected $table = 'server_transfers';4041/**42* Fields that are not mass assignable.43*/44protected $guarded = ['id', 'created_at', 'updated_at'];4546/**47* Cast values to correct type.48*/49protected $casts = [50'server_id' => 'int',51'old_node' => 'int',52'new_node' => 'int',53'old_allocation' => 'int',54'new_allocation' => 'int',55'old_additional_allocations' => 'array',56'new_additional_allocations' => 'array',57'successful' => 'bool',58'archived' => 'bool',59];6061public static array $validationRules = [62'server_id' => 'required|numeric|exists:servers,id',63'old_node' => 'required|numeric',64'new_node' => 'required|numeric',65'old_allocation' => 'required|numeric',66'new_allocation' => 'required|numeric',67'old_additional_allocations' => 'nullable|array',68'old_additional_allocations.*' => 'numeric',69'new_additional_allocations' => 'nullable|array',70'new_additional_allocations.*' => 'numeric',71'successful' => 'sometimes|nullable|boolean',72];7374/**75* Gets the server associated with a server transfer.76*77* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\Server, $this>78*/79public function server(): BelongsTo80{81return $this->belongsTo(Server::class);82}8384/**85* Gets the source node associated with a server transfer.86*87* @return \Illuminate\Database\Eloquent\Relations\HasOne<\Pterodactyl\Models\Node, $this>88*/89public function oldNode(): HasOne90{91return $this->hasOne(Node::class, 'id', 'old_node');92}9394/**95* Gets the target node associated with a server transfer.96*97* @return \Illuminate\Database\Eloquent\Relations\HasOne<\Pterodactyl\Models\Node, $this>98*/99public function newNode(): HasOne100{101return $this->hasOne(Node::class, 'id', 'new_node');102}103}104105106