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 Database\Factories\ServerTransferFactory;
|
|
|
|
|
use Illuminate\Database\Eloquent\Attributes\Guarded;
|
2026-03-26 19:53:41 -04:00
|
|
|
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
|
|
|
/**
|
2026-10-11 22:55:07 -04:00
|
|
|
* @property-read Server $server
|
|
|
|
|
* @property-read 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> */
|
2026-03-26 19:53:41 -04:00
|
|
|
use HasFactory;
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
/**
|
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
|
|
|
|
|
|
|
|
/**
|
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');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
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
|
|
|
}
|