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.

73 lines
2.2 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <?php
  2. namespace Database\Seeders;
  3. use App\Image\ImageProcessor;
  4. use App\Models\Collection;
  5. use App\Models\File;
  6. use Illuminate\Database\Console\Seeds\WithoutModelEvents;
  7. use Illuminate\Database\Seeder;
  8. use Illuminate\Support\Facades\Storage;
  9. class DatabaseSeeder extends Seeder
  10. {
  11. /**
  12. * Seed the application's database.
  13. *
  14. * @return void
  15. */
  16. public function run()
  17. {
  18. // \App\Models\User::factory(10)->create();
  19. // \App\Models\User::factory()->create([
  20. // 'name' => 'Test User',
  21. // 'email' => 'test@example.com',
  22. // ]);
  23. // \App\Models\Collection::factory()->create([
  24. // "name" => "fuck",
  25. // "count" => 1,
  26. // "tmp_support" => 0,
  27. // "remove_tmp_time" => 132,
  28. // "max_file_size" => 100000000,
  29. // "min_file_size" => 10,
  30. // "max_width" =>2000,
  31. // "min_width" =>10,
  32. // "max_height" => 2000,
  33. // "min_height" =>10,
  34. // "alt_required" => 0,
  35. // "description_required" =>0,
  36. // "exts" => [
  37. // "jpg",
  38. // "jpeg",
  39. // "png",
  40. // "webp"
  41. // ],
  42. // "ext" => "webp",
  43. // ]);
  44. // \App\Models\Collection::factory(10)->create();
  45. // \App\Models\File::factory()->create();
  46. $collection = Collection::factory()->createQuietly([
  47. 'alt_required' => false,
  48. 'description_required' => false,
  49. 'tmp_support' => true,
  50. 'max_width' => 2000,
  51. 'max_height' => 2000,
  52. 'min_width' => 1,
  53. 'min_height' => 1,
  54. 'min_file_size' => 0,
  55. 'public' => false
  56. ]);
  57. $uuid = app()->uuid;
  58. $file = File::factory()->createQuietly([
  59. 'uuid' => $uuid,
  60. 'server_path' => '/' . date('y') . '/' . date('m') . '/',
  61. 'user_id' => auth()->id(),
  62. 'collection_id' => $collection->id
  63. ]);
  64. $imageProcessor = new ImageProcessor;
  65. $imageProcessor->createFakeImage(storage_path('stub') . '/image.png', Storage::disk($collection->disk)->path($file->server_path . $uuid . '.' . $collection->ext));
  66. }
  67. }