49 lines
1.8 KiB
PHP
49 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders\Development;
|
|
|
|
use App\Lib\Helpers\FileStorageHelper;
|
|
use App\Models\HistoricalMilestone;
|
|
use Illuminate\Database\Seeder;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\File;
|
|
|
|
class HistoricalMilestoneSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeds.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function run()
|
|
{
|
|
DB::table((new HistoricalMilestone())->getTable())->truncate();
|
|
File::deleteDirectory(\storage_path('app/public/modelfiles/' . (new HistoricalMilestone())->getTable()));
|
|
|
|
HistoricalMilestone::factory(7)->make()->each(function (HistoricalMilestone $historicalMilestone) {
|
|
$historicalMilestone->picture1 = FileStorageHelper::storeFile(
|
|
new HistoricalMilestone(),
|
|
new \SplFileInfo(
|
|
\resource_path('../database/factories/assets/historicalmilestones/default-picture-431x300.png')
|
|
)
|
|
);
|
|
if ($second = fake()->boolean(75)) {
|
|
$historicalMilestone->picture2 = FileStorageHelper::storeFile(
|
|
new HistoricalMilestone(),
|
|
new \SplFileInfo(
|
|
\resource_path('../database/factories/assets/historicalmilestones/default-picture-431x300.png')
|
|
)
|
|
);
|
|
}
|
|
if ($second && fake()->boolean(75)) {
|
|
$historicalMilestone->picture3 = FileStorageHelper::storeFile(
|
|
new HistoricalMilestone(),
|
|
new \SplFileInfo(
|
|
\resource_path('../database/factories/assets/historicalmilestones/default-picture-431x300.png')
|
|
)
|
|
);
|
|
}
|
|
$historicalMilestone->saveQuietly();
|
|
});
|
|
}
|
|
}
|