ldc-tregalette/database/seeders/Development/ReductionSeeder.php

34 lines
947 B
PHP
Raw Permalink Normal View History

2023-12-15 15:53:55 +00:00
<?php
2023-12-18 12:42:06 +01:00
namespace Database\Seeders\Development;
2023-12-15 15:53:55 +00:00
use App\Lib\Helpers\FileStorageHelper;
use App\Models\Reduction;
use Illuminate\Database\Seeder;
2023-12-18 12:42:06 +01:00
use Illuminate\Support\Facades\DB;
2023-12-18 11:33:22 +01:00
use Illuminate\Support\Facades\File;
2023-12-15 15:53:55 +00:00
class ReductionSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
2023-12-18 12:42:06 +01:00
DB::table((new Reduction())->getTable())->truncate();
2023-12-18 11:33:22 +01:00
File::deleteDirectory(\storage_path('app/public/modelfiles/' . (new Reduction())->getTable()));
2023-12-15 15:53:55 +00:00
Reduction::factory(10)->make()->each(function (Reduction $reduction) {
$reduction->picture_packshot = FileStorageHelper::storeFile(
new Reduction(),
new \SplFileInfo(
\resource_path('../database/factories/assets/reductions/default-picture-266x266.png')
)
);
$reduction->saveQuietly();
});
}
}