CommentFactory.php 680 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace Database\Factories;
  3. use Illuminate\Database\Eloquent\Factories\Factory;
  4. use App\Models\User;
  5. use App\Models\Blog;
  6. /**
  7. * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Comment>
  8. */
  9. class CommentFactory extends Factory
  10. {
  11. /**
  12. * Define the model's default state.
  13. *
  14. * @return array<string, mixed>
  15. */
  16. public function definition()
  17. {
  18. return [
  19. 'authorId' => $this->faker->randomElement(User::query()->get('id')),
  20. 'comment' => $this->faker->realText($maxNbChars = 200, $indexSize = 2),
  21. 'blogId' => $this->faker->randomElement(Blog::query()->get('id')),
  22. ];
  23. }
  24. }