2026-03-26 19:53:41 -04:00
|
|
|
<?php
|
|
|
|
|
|
2026-10-05 18:10:18 -04:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2026-03-26 19:53:41 -04:00
|
|
|
namespace Database\Factories;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
2026-10-05 18:10:18 -04:00
|
|
|
use Pterodactyl\Models\Allocation;
|
|
|
|
|
use Pterodactyl\Models\Node;
|
|
|
|
|
use Pterodactyl\Models\Server;
|
|
|
|
|
use Pterodactyl\Models\ServerTransfer;
|
2026-03-26 19:53:41 -04:00
|
|
|
|
2026-10-05 18:10:18 -04:00
|
|
|
/**
|
|
|
|
|
* @extends Factory<ServerTransfer>
|
|
|
|
|
*/
|
2026-03-26 19:53:41 -04:00
|
|
|
class ServerTransferFactory extends Factory
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* The name of the factory's corresponding model.
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
protected $model = ServerTransfer::class;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Define the model's default state.
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function definition()
|
|
|
|
|
{
|
|
|
|
|
return [
|
2026-10-05 18:10:18 -04:00
|
|
|
'server_id' => Server::factory()->withRelationships(),
|
|
|
|
|
'old_node' => fn (array $attributes) => Server::query()->findOrFail($attributes['server_id'])->node_id,
|
|
|
|
|
'old_allocation' => fn (array $attributes) => Server::query()->findOrFail($attributes['server_id'])->allocation_id,
|
|
|
|
|
'new_node' => Node::factory()->withLocation(),
|
|
|
|
|
'new_allocation' => fn (array $attributes) => Allocation::factory()->create(['node_id' => $attributes['new_node']])->id,
|
2026-03-26 19:53:41 -04:00
|
|
|
'old_additional_allocations' => [],
|
|
|
|
|
'new_additional_allocations' => [],
|
|
|
|
|
'successful' => null,
|
|
|
|
|
'archived' => false,
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|