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 [
|
2026-08-15 10:07:40 +02:00
|
|
|
// 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',
|
|
|
|
|
]);
|
|
|
|
|
}
|
2026-03-08 14:17:55 +01:00
|
|
|
}
|