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.

52 lines
1.5 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <?php
  2. namespace Database\Factories;
  3. use App\Models\Collection;
  4. use Illuminate\Database\Eloquent\Factories\Factory;
  5. use Illuminate\Support\Facades\App;
  6. use Illuminate\Support\Str;
  7. /**
  8. * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\File>
  9. */
  10. class FileFactory extends Factory
  11. {
  12. use BaseFactory;
  13. /**
  14. * Define the model's default state.
  15. *
  16. * @return array<string, mixed>
  17. */
  18. public function definition()
  19. {
  20. return [
  21. "uuid" => app()->uuid,
  22. "original_name" => fake()->name(),
  23. "ext" => ['jpg', 'jpeg', 'png', 'webp'][rand(0, 3)],
  24. "mimetype" => 'image',
  25. "width" => rand(300, 2000),
  26. "height" => rand(300, 2000),
  27. "file_size" => rand(300, 2000),
  28. "sort" => rand(0, 23),
  29. "server_path" => '/' . date('y') . '/' . date('m') . '/',
  30. "alts" => [
  31. 'hello wroldswdfouiwref iuwrhgf ow rgfaw ghfawej',
  32. 'jhsf asduyfsadf sadf safsuf isfjsdfsudifsduiyf sdiuf sd'
  33. ],
  34. "description" => 'ajsfoisahjfoaspf asduf safsafjsh lh',
  35. "user_id" => rand(43724, 382348),
  36. "ip" => "127.0. 0.1",
  37. // "collection_id" => $collection->id,
  38. "published_at" => "2022-07-27 09:17:59",
  39. ];
  40. }
  41. public function dependencyProvider()
  42. {
  43. return [
  44. 'collection_id' => Collection::factory()->createQuietly()
  45. ];
  46. }
  47. }