Files
pterodactyl-panel/app/Models/ServerTransfer.php
T

91 lines
2.3 KiB
PHP
Raw Normal View History

2020-04-04 11:37:44 -06:00
<?php
2026-10-05 18:10:18 -04:00
declare(strict_types=1);
2020-04-04 11:37:44 -06:00
namespace Pterodactyl\Models;
2026-10-05 18:10:18 -04:00
use Carbon\Carbon;
use Database\Factories\ServerTransferFactory;
use Illuminate\Database\Eloquent\Attributes\Guarded;
use Illuminate\Database\Eloquent\Factories\HasFactory;
2026-10-05 18:10:18 -04:00
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasOne;
2022-10-14 10:59:20 -06:00
2020-04-04 11:37:44 -06:00
/**
* @property int $id
* @property int $server_id
* @property int $old_node
* @property int $new_node
* @property int $old_allocation
* @property int $new_allocation
2026-10-05 18:10:18 -04:00
* @property list<int>|null $old_additional_allocations
* @property list<int>|null $new_additional_allocations
* @property bool|null $successful
* @property bool $archived
2026-10-05 18:10:18 -04:00
* @property Carbon $created_at
* @property Carbon $updated_at
2024-10-21 19:18:20 -06:00
* @property Server $server
* @property Node $oldNode
* @property Node $newNode
2020-04-04 11:37:44 -06:00
*/
2026-10-05 18:10:18 -04:00
#[Guarded(['id', 'created_at', 'updated_at'])]
2020-06-06 11:37:43 -06:00
class ServerTransfer extends Model
2020-04-04 11:37:44 -06:00
{
2026-10-05 18:10:18 -04:00
/** @use HasFactory<ServerTransferFactory> */
use HasFactory;
2020-04-04 11:37:44 -06:00
/**
* The resource name for this model when it is transformed into an
* API representation using fractal.
*/
2026-10-05 18:10:18 -04:00
public const string RESOURCE_NAME = 'server_transfer';
2020-04-04 11:37:44 -06:00
/**
2026-10-05 18:10:18 -04:00
* @return array<string, string>
2020-04-04 11:37:44 -06:00
*/
2026-10-05 18:10:18 -04:00
protected function casts(): array
{
return [
'server_id' => 'int',
'old_node' => 'int',
'new_node' => 'int',
'old_allocation' => 'int',
'new_allocation' => 'int',
'old_additional_allocations' => 'array',
'new_additional_allocations' => 'array',
'successful' => 'bool',
'archived' => 'bool',
];
}
2020-04-04 11:37:44 -06:00
/**
* Gets the server associated with a server transfer.
*
2026-10-05 18:10:18 -04:00
* @return BelongsTo<Server, $this>
2020-04-04 11:37:44 -06:00
*/
2022-10-14 10:59:20 -06:00
public function server(): BelongsTo
2020-04-04 11:37:44 -06:00
{
return $this->belongsTo(Server::class);
}
2020-12-16 16:55:44 -07:00
/**
* Gets the source node associated with a server transfer.
*
2026-10-05 18:10:18 -04:00
* @return HasOne<Node, $this>
2020-12-16 16:55:44 -07:00
*/
2022-10-14 10:59:20 -06:00
public function oldNode(): HasOne
2020-12-16 16:55:44 -07:00
{
return $this->hasOne(Node::class, 'id', 'old_node');
}
/**
* Gets the target node associated with a server transfer.
*
2026-10-05 18:10:18 -04:00
* @return HasOne<Node, $this>
2020-12-16 16:55:44 -07:00
*/
2022-10-14 10:59:20 -06:00
public function newNode(): HasOne
2020-12-16 16:55:44 -07:00
{
return $this->hasOne(Node::class, 'id', 'new_node');
}
2020-04-04 11:37:44 -06:00
}