You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.2 KiB

  1. <?php
  2. /** @var Factory $factory */
  3. use App\Models\File;
  4. use Faker\Generator as Faker;
  5. $factory->define(File::class, function (Faker $faker) {
  6. $mimes = ['application/pdf', 'video/mp4', 'image/png', 'image/jpeg', 'audio/x-wav'];
  7. $extensions = ['pdf', 'mp4', 'png', 'jpg', 'wav'];
  8. $groups = [
  9. 'pdf' => 'pdf',
  10. 'mp4' => 'video',
  11. 'png' => 'image',
  12. 'jpg' => 'image',
  13. 'wav' => 'audio',
  14. ];
  15. $sizes = [1, 5, 128, 256, 1024, 2048];
  16. $rand_type = $faker->numberBetween(0, 4);
  17. return [
  18. 'user_id' => $faker->numberBetween(1, 200),
  19. 'business_id' => $faker->numberBetween(1, 200),
  20. 'project_id' => $faker->numberBetween(1, 200),
  21. 'attached_to_id' => $faker->numberBetween(1, 100),
  22. 'attached_to_table' => enum('tables.tasks.id'),
  23. 'disk' => 's3',
  24. 'original_name' => $faker->words(1, true),
  25. 'name' => $faker->words(1, true),
  26. 'extension' => $extension = $extensions[$rand_type],
  27. 'mime' => $mimes[$rand_type],
  28. 'group' => $groups[$extension],
  29. 'size' => $sizes[$faker->numberBetween(0, 5)],
  30. 'description' => $faker->text,
  31. ];
  32. });