PostFactory.php 600 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace Database\Factories;
  3. use App\Models\Post;
  4. use App\Models\User;
  5. use Illuminate\Database\Eloquent\Factories\Factory;
  6. class PostFactory extends Factory
  7. {
  8. /**
  9. * The name of the factory's corresponding model.
  10. *
  11. * @var string
  12. */
  13. protected $model = Post::class;
  14. /**
  15. * Define the model's default state.
  16. *
  17. * @return array
  18. */
  19. public function definition()
  20. {
  21. return [
  22. 'title' => $this->faker->sentence,
  23. 'content' => $this->faker->paragraph,
  24. 'user_id' => User::factory()
  25. ];
  26. }
  27. }