Files
pterodactyl-panel/database/Factories/DatabaseFactory.php
T

53 lines
1.3 KiB
PHP
Raw Normal View History

2021-01-23 12:09:16 -08:00
<?php
2026-10-05 18:10:18 -04:00
declare(strict_types=1);
2021-01-23 12:09:16 -08:00
namespace Database\Factories;
2026-10-05 18:10:18 -04:00
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Date;
2021-01-23 12:09:16 -08:00
use Illuminate\Support\Str;
use Pterodactyl\Models\Database;
2026-10-05 18:10:18 -04:00
use Pterodactyl\Models\DatabaseHost;
use Pterodactyl\Models\Server;
2021-01-23 12:09:16 -08:00
2026-10-05 18:10:18 -04:00
/**
* @extends Factory<Database>
*/
2021-01-23 12:09:16 -08:00
class DatabaseFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Database::class;
/**
* Define the model's default state.
*/
public function definition(): array
{
static $password;
return [
2026-10-05 18:10:18 -04:00
'server_id' => Server::factory()->withRelationships(),
'database_host_id' => DatabaseHost::factory(),
2021-01-23 12:09:16 -08:00
'database' => Str::random(10),
'username' => Str::random(10),
'remote' => '%',
'password' => $password ?: encrypt('test123'),
2026-10-05 18:10:18 -04:00
'created_at' => Date::now(),
'updated_at' => Date::now(),
2021-01-23 12:09:16 -08:00
];
}
2026-10-05 18:10:18 -04:00
public function withServerAndHost(): self
{
return $this->state(fn (): array => [
'server_id' => Server::factory()->withRelationships()->create()->id,
'database_host_id' => DatabaseHost::factory()->create()->id,
]);
}
2021-01-23 12:09:16 -08:00
}