Path: blob/1.0-develop/app/Models/ServerTransfer.php
10266 views
<?php12namespace Pterodactyl\Models;34use Illuminate\Database\Eloquent\Relations\HasOne;5use Illuminate\Database\Eloquent\Relations\BelongsTo;67/**8* @property int $id9* @property int $server_id10* @property int $old_node11* @property int $new_node12* @property int $old_allocation13* @property int $new_allocation14* @property array|null $old_additional_allocations15* @property array|null $new_additional_allocations16* @property bool|null $successful17* @property bool $archived18* @property \Carbon\Carbon $created_at19* @property \Carbon\Carbon $updated_at20* @property Server $server21* @property Node $oldNode22* @property Node $newNode23*/24class ServerTransfer extends Model25{26/**27* The resource name for this model when it is transformed into an28* API representation using fractal.29*/30public const RESOURCE_NAME = 'server_transfer';3132/**33* The table associated with the model.34*/35protected $table = 'server_transfers';3637/**38* Fields that are not mass assignable.39*/40protected $guarded = ['id', 'created_at', 'updated_at'];4142/**43* Cast values to correct type.44*/45protected $casts = [46'server_id' => 'int',47'old_node' => 'int',48'new_node' => 'int',49'old_allocation' => 'int',50'new_allocation' => 'int',51'old_additional_allocations' => 'array',52'new_additional_allocations' => 'array',53'successful' => 'bool',54'archived' => 'bool',55];5657public static array $validationRules = [58'server_id' => 'required|numeric|exists:servers,id',59'old_node' => 'required|numeric',60'new_node' => 'required|numeric',61'old_allocation' => 'required|numeric',62'new_allocation' => 'required|numeric',63'old_additional_allocations' => 'nullable|array',64'old_additional_allocations.*' => 'numeric',65'new_additional_allocations' => 'nullable|array',66'new_additional_allocations.*' => 'numeric',67'successful' => 'sometimes|nullable|boolean',68];6970/**71* Gets the server associated with a server transfer.72*73* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\Server, $this>74*/75public function server(): BelongsTo76{77return $this->belongsTo(Server::class);78}7980/**81* Gets the source node associated with a server transfer.82*83* @return \Illuminate\Database\Eloquent\Relations\HasOne<\Pterodactyl\Models\Node, $this>84*/85public function oldNode(): HasOne86{87return $this->hasOne(Node::class, 'id', 'old_node');88}8990/**91* Gets the target node associated with a server transfer.92*93* @return \Illuminate\Database\Eloquent\Relations\HasOne<\Pterodactyl\Models\Node, $this>94*/95public function newNode(): HasOne96{97return $this->hasOne(Node::class, 'id', 'new_node');98}99}100101102