presseportale/database/factories/CategoryFactory.php
Kevin Adametz 5b8bdf4182
Some checks are pending
linter / quality (push) Waiting to run
tests / ci (push) Waiting to run
12-05-2026 Frontend dev
2026-05-12 18:32:33 +02:00

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)],
]);
});
}
}