ldc-volena/database/seeders/Development/TestimonialSeeder.php

37 lines
1,011 B
PHP
Raw Permalink Normal View History

2023-11-16 09:42:21 +01:00
<?php
namespace Database\Seeders\Development;
2023-11-16 09:42:21 +01:00
use App\Enums\Testimonials\TypeEnum;
use App\Lib\Helpers\FileStorageHelper;
use App\Models\Testimonial;
use Illuminate\Database\Seeder;
/**
* @package Database\Seeders\Development
*/
2023-11-16 09:42:21 +01:00
class TestimonialSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
FileStorageHelper::removeModelFiles(new Testimonial());
foreach (TypeEnum::cases() as $type) {
Testimonial::factory(3)->make()->each(function (Testimonial $testimonial) use ($type) {
$testimonial->type = $type;
2023-11-16 09:42:21 +01:00
$testimonial->picture = FileStorageHelper::storeFile(
new Testimonial(),
new \SplFileInfo(\resource_path(
'../database/factories/assets/testimonials/default-picture-100x100.png'
))
);
$testimonial->save();
});
}
}
}