presseportale/database/factories/PressReleaseFactory.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

58 lines
1.6 KiB
PHP

<?php
namespace Database\Factories;
use App\Enums\Portal;
use App\Enums\PressReleaseStatus;
use App\Models\Category;
use App\Models\Company;
use App\Models\PressRelease;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* @extends Factory<PressRelease>
*/
class PressReleaseFactory extends Factory
{
protected $model = PressRelease::class;
public function definition(): array
{
$title = fake()->sentence(6);
return [
'uuid' => (string) Str::uuid(),
'portal' => fake()->randomElement([Portal::Presseecho->value, Portal::Businessportal24->value]),
'user_id' => User::factory(),
'company_id' => Company::factory(),
'category_id' => Category::factory(),
'language' => 'de',
'title' => $title,
'slug' => Str::slug($title).'-'.fake()->unique()->numberBetween(1000, 9999),
'text' => fake()->paragraphs(3, true),
'status' => PressReleaseStatus::Draft->value,
'hits' => 0,
'no_export' => false,
];
}
public function published(): static
{
return $this->state([
'status' => PressReleaseStatus::Published->value,
'published_at' => now(),
]);
}
public function inReview(): static
{
return $this->state(['status' => PressReleaseStatus::Review->value]);
}
public function forPortal(Portal $portal): static
{
return $this->state(['portal' => $portal->value]);
}
}