fedi-feed-router/database/factories/LanguageFactory.php

43 lines
1 KiB
PHP
Raw Permalink Normal View History

2025-07-06 01:35:59 +02:00
<?php
namespace Database\Factories;
use App\Models\Language;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<Language>
*/
class LanguageFactory extends Factory
{
protected $model = Language::class;
public function definition(): array
{
return [
// Not a real language code: tests hardcode 'en', 'fr', 'nl' and
// others, and faker's pool would collide with them.
'short_code' => 'x-'.$this->faker->unique()->numerify('####'),
2025-07-06 01:35:59 +02:00
'name' => $this->faker->unique()->word(),
'native_name' => $this->faker->optional()->word(),
'is_active' => true,
];
}
public function inactive(): static
{
return $this->state(fn (array $attributes) => [
'is_active' => false,
]);
}
public function english(): static
{
return $this->state(fn (array $attributes) => [
'short_code' => 'en',
'name' => 'English',
'native_name' => 'English',
]);
}
}