Files

62 lines
1.4 KiB
PHP
Raw Permalink 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;
2021-01-23 12:09:16 -08:00
use Illuminate\Support\Str;
2026-10-05 18:10:18 -04:00
use Pterodactyl\Models\Egg;
2021-01-23 12:09:16 -08:00
use Pterodactyl\Models\EggVariable;
2026-10-05 18:10:18 -04:00
/**
* @extends Factory<EggVariable>
*/
2021-01-23 12:09:16 -08:00
class EggVariableFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = EggVariable::class;
/**
* Define the model's default state.
*/
public function definition(): array
{
return [
2026-10-05 18:10:18 -04:00
'egg_id' => Egg::factory(),
'name' => fake()->unique()->firstName(),
'description' => fake()->sentence(),
'env_variable' => Str::upper(Str::replaceArray(' ', ['_'], fake()->words(2, true))),
'default_value' => fake()->colorName(),
2021-01-23 12:09:16 -08:00
'user_viewable' => 0,
'user_editable' => 0,
'rules' => 'required|string',
2026-10-05 18:10:18 -04:00
'sort_order' => 0,
2021-01-23 12:09:16 -08:00
];
}
/**
* Indicate that the egg variable is viewable.
*/
2023-02-23 12:30:16 -07:00
public function viewable(): static
2021-01-23 12:09:16 -08:00
{
2026-10-05 18:10:18 -04:00
return $this->state(fn (array $attributes): array => [
'user_viewable' => 1,
]);
2021-01-23 12:09:16 -08:00
}
/**
* Indicate that the egg variable is editable.
*/
2023-02-23 12:30:16 -07:00
public function editable(): static
2021-01-23 12:09:16 -08:00
{
2026-10-05 18:10:18 -04:00
return $this->state(fn (array $attributes): array => [
'user_editable' => 1,
]);
2021-01-23 12:09:16 -08:00
}
}