36 lines
983 B
PHP
36 lines
983 B
PHP
<?php
|
|
|
|
namespace Database\Seeders\Development;
|
|
|
|
use App\Lib\Helpers\FileStorageHelper;
|
|
use App\Models\Testimonial;
|
|
use Illuminate\Database\Seeder;
|
|
|
|
class TestimonialSeeder extends Seeder
|
|
{
|
|
/**
|
|
* The name of the factory's corresponding model.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $model = Testimonial::class;
|
|
|
|
/**
|
|
* Run the database seeds.
|
|
*/
|
|
public function run(): void
|
|
{
|
|
Testimonial::factory(10)->make()->each(function (Testimonial $testimonial, int $key) {
|
|
$testimonial->picture = FileStorageHelper::storeFile(
|
|
$testimonial,
|
|
new \SplFileInfo(\resource_path(
|
|
'../database/factories/assets/testimonials/default-picture-550x315.png'
|
|
))
|
|
);
|
|
$testimonial->order = $key + 1;
|
|
$testimonial->saveQuietly();
|
|
});
|
|
|
|
Testimonial::query()->inRandomOrder()->limit(rand(1, 5))->update(['published' => true]);
|
|
}
|
|
}
|