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
73 lines
2.2 KiB
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use App\Image\ImageProcessor;
|
|
use App\Models\Collection;
|
|
use App\Models\File;
|
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
|
use Illuminate\Database\Seeder;
|
|
use Illuminate\Support\Facades\Storage;
|
|
|
|
class DatabaseSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Seed the application's database.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function run()
|
|
{
|
|
// \App\Models\User::factory(10)->create();
|
|
|
|
// \App\Models\User::factory()->create([
|
|
// 'name' => 'Test User',
|
|
// 'email' => 'test@example.com',
|
|
// ]);
|
|
|
|
// \App\Models\Collection::factory()->create([
|
|
// "name" => "fuck",
|
|
// "count" => 1,
|
|
// "tmp_support" => 0,
|
|
// "remove_tmp_time" => 132,
|
|
// "max_file_size" => 100000000,
|
|
// "min_file_size" => 10,
|
|
// "max_width" =>2000,
|
|
// "min_width" =>10,
|
|
// "max_height" => 2000,
|
|
// "min_height" =>10,
|
|
// "alt_required" => 0,
|
|
// "description_required" =>0,
|
|
// "exts" => [
|
|
// "jpg",
|
|
// "jpeg",
|
|
// "png",
|
|
// "webp"
|
|
// ],
|
|
// "ext" => "webp",
|
|
// ]);
|
|
// \App\Models\Collection::factory(10)->create();
|
|
// \App\Models\File::factory()->create();
|
|
$collection = Collection::factory()->createQuietly([
|
|
'alt_required' => false,
|
|
'description_required' => false,
|
|
'tmp_support' => true,
|
|
'max_width' => 2000,
|
|
'max_height' => 2000,
|
|
'min_width' => 1,
|
|
'min_height' => 1,
|
|
'min_file_size' => 0,
|
|
'public' => false
|
|
]);
|
|
$uuid = app()->uuid;
|
|
$file = File::factory()->createQuietly([
|
|
'uuid' => $uuid,
|
|
'server_path' => '/' . date('y') . '/' . date('m') . '/',
|
|
'user_id' => auth()->id(),
|
|
'collection_id' => $collection->id
|
|
]);
|
|
$imageProcessor = new ImageProcessor;
|
|
$imageProcessor->createFakeImage(storage_path('stub') . '/image.png', Storage::disk($collection->disk)->path($file->server_path . $uuid . '.' . $collection->ext));
|
|
|
|
}
|
|
}
|