ldc-legaulois/database/seeders/Development/DemarcheSlideSeeder.php

35 lines
909 B
PHP
Raw Permalink Normal View History

2024-04-12 12:15:18 +02:00
<?php
namespace Database\Seeders\Development;
use App\Lib\Helpers\FileStorageHelper;
use App\Models\DemarcheSlide;
use Illuminate\Database\Seeder;
class DemarcheSlideSeeder extends Seeder
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = DemarcheSlide::class;
2024-04-12 12:15:18 +02:00
/**
* Run the database seeds.
*/
2024-04-19 10:08:36 +02:00
public function run(): void
2024-04-12 12:15:18 +02:00
{
DemarcheSlide::factory(5)->make()->each(function (DemarcheSlide $demarcheSlide, int $key) {
$demarcheSlide->picture = FileStorageHelper::storeFile(
$demarcheSlide,
new \SplFileInfo(\resource_path(
'../database/factories/assets/demarche_slides/default-picture-200x200.png'
))
);
$demarcheSlide->order = $key + 1;
$demarcheSlide->saveQuietly();
});
}
}