BlogFactory.php 765 B

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