33 lines
956 B
PHP
33 lines
956 B
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Enums\Portal;
|
|
use App\Models\Category;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends Factory<Category>
|
|
*/
|
|
class CategoryFactory extends Factory
|
|
{
|
|
protected $model = Category::class;
|
|
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'portal' => fake()->randomElement([Portal::Presseecho->value, Portal::Businessportal24->value, Portal::Both->value]),
|
|
'is_active' => true,
|
|
];
|
|
}
|
|
|
|
public function withTranslations(): static
|
|
{
|
|
return $this->afterCreating(function (Category $category): void {
|
|
$category->translations()->createMany([
|
|
['locale' => 'de', 'name' => fake('de_DE')->words(2, true), 'slug' => 'de-'.fake()->unique()->slug(2)],
|
|
['locale' => 'en', 'name' => fake('en_US')->words(2, true), 'slug' => 'en-'.fake()->unique()->slug(2)],
|
|
]);
|
|
});
|
|
}
|
|
}
|