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

45 lines
1.2 KiB
PHP

<?php
namespace Database\Factories;
use App\Models\Article;
use App\Models\Feed;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<Article>
*/
class ArticleFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'feed_id' => Feed::factory(),
'url' => $this->faker->unique()->url(),
'title' => $this->faker->sentence(),
'description' => $this->faker->paragraph(),
'content' => $this->faker->paragraphs(3, true),
'image_url' => $this->faker->imageUrl(),
'published_at' => $this->faker->optional()->dateTimeBetween('-1 month', 'now'),
'author' => $this->faker->optional()->name(),
];
}
/**
* An article discovered but never validated, so publishing must fetch its data live.
*/
public function unvalidated(): static
{
return $this->state(fn (array $attributes): array => [
'description' => null,
'content' => null,
'image_url' => null,
'validated_at' => null,
]);
}
}