37 lines
806 B
PHP
Raw Normal View History

2025-01-23 00:19:07 +01:00
<?php
namespace Database\Factories;
use App\Models\Category;
use App\Models\Post;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Post>
*/
class PostFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Post::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'title' => $this->faker->sentence,
'content' => $this->faker->paragraphs(3, true),
'category_id' => Category::inRandomOrder()->first()->id ?? null,
'created_at' => now(),
'updated_at' => now(),
];
}
}