2021-01-23 12:09:16 -08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Database\Factories;
|
|
|
|
|
|
2024-10-26 20:35:25 -04:00
|
|
|
use App\Models\Allocation;
|
|
|
|
|
use App\Models\Egg;
|
|
|
|
|
use App\Models\Node;
|
|
|
|
|
use App\Models\User;
|
2021-01-23 12:09:16 -08:00
|
|
|
use Carbon\Carbon;
|
|
|
|
|
use Ramsey\Uuid\Uuid;
|
|
|
|
|
use Illuminate\Support\Str;
|
2024-03-12 22:39:16 -04:00
|
|
|
use App\Models\Server;
|
2021-01-23 12:09:16 -08:00
|
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
|
|
|
|
|
|
class ServerFactory extends Factory
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* The name of the factory's corresponding model.
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
protected $model = Server::class;
|
|
|
|
|
|
2024-10-26 20:35:25 -04:00
|
|
|
public function withNode(?Node $node = null): static
|
|
|
|
|
{
|
|
|
|
|
$node ??= Node::factory()->create();
|
|
|
|
|
|
|
|
|
|
return $this->state(fn () => [
|
|
|
|
|
'node_id' => $node->id,
|
|
|
|
|
'allocation_id' => Allocation::factory([
|
|
|
|
|
'node_id' => $node->id,
|
|
|
|
|
]),
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-23 12:09:16 -08:00
|
|
|
/**
|
|
|
|
|
* Define the model's default state.
|
|
|
|
|
*/
|
2024-03-19 21:12:27 -04:00
|
|
|
public function definition(): array
|
2021-01-23 12:09:16 -08:00
|
|
|
{
|
|
|
|
|
return [
|
2024-10-26 20:35:25 -04:00
|
|
|
'owner_id' => User::factory(),
|
|
|
|
|
'node_id' => Node::factory(),
|
|
|
|
|
'allocation_id' => Allocation::factory(),
|
|
|
|
|
'egg_id' => Egg::factory(),
|
2021-01-23 12:09:16 -08:00
|
|
|
'uuid' => Uuid::uuid4()->toString(),
|
2024-04-13 21:51:22 -04:00
|
|
|
'uuid_short' => Str::lower(Str::random(8)),
|
2024-03-19 16:47:02 -04:00
|
|
|
'name' => $this->faker->firstName(),
|
2021-01-23 12:09:16 -08:00
|
|
|
'description' => implode(' ', $this->faker->sentences()),
|
|
|
|
|
'skip_scripts' => 0,
|
2021-01-30 19:12:22 -08:00
|
|
|
'status' => null,
|
2021-01-23 12:09:16 -08:00
|
|
|
'memory' => 512,
|
|
|
|
|
'swap' => 0,
|
|
|
|
|
'disk' => 512,
|
|
|
|
|
'io' => 500,
|
|
|
|
|
'cpu' => 0,
|
|
|
|
|
'threads' => null,
|
2024-05-08 09:51:08 +02:00
|
|
|
'oom_killer' => false,
|
2022-05-29 17:07:34 -04:00
|
|
|
'startup' => '/bin/bash echo "hello world"',
|
|
|
|
|
'image' => 'foo/bar:latest',
|
2022-05-29 17:52:14 -04:00
|
|
|
'allocation_limit' => null,
|
|
|
|
|
'database_limit' => null,
|
2022-05-29 17:07:34 -04:00
|
|
|
'backup_limit' => 0,
|
2021-01-23 12:09:16 -08:00
|
|
|
'created_at' => Carbon::now(),
|
|
|
|
|
'updated_at' => Carbon::now(),
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|