39 lines
1.1 KiB
PHP
39 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders\Development;
|
|
|
|
use App\Enums\Testimonials\TypeEnum;
|
|
use App\Lib\Helpers\FileStorageHelper;
|
|
use App\Models\Testimonial;
|
|
use Illuminate\Database\Seeder;
|
|
|
|
/**
|
|
* FIXME: Definir les tailes d'images pour les testimonials
|
|
*
|
|
* @package Database\Seeders\Development
|
|
*/
|
|
class TestimonialSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeds.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function run()
|
|
{
|
|
FileStorageHelper::removeModelFiles(new Testimonial());
|
|
foreach (TypeEnum::cases() as $type) {
|
|
// @phpstan-ignore-next-line
|
|
Testimonial::factory(3)->make()->each(function (Testimonial $testimonial) use ($type) {
|
|
$testimonial->type = $type;
|
|
$testimonial->picture = FileStorageHelper::storeFile(
|
|
new Testimonial(),
|
|
new \SplFileInfo(\resource_path(
|
|
'../database/factories/assets/testimonials/default-picture-100x100.png'
|
|
))
|
|
);
|
|
$testimonial->save();
|
|
});
|
|
}
|
|
}
|
|
}
|