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

34 lines
802 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\Approach;
use Illuminate\Database\Seeder;
class ApproachSeeder extends Seeder
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Approach::class;
/**
* Run the database seeds.
*/
2024-04-19 10:08:36 +02:00
public function run(): void
2024-04-12 12:15:18 +02:00
{
Approach::factory(10)->make()->each(function (Approach $approach) {
$approach->picture = FileStorageHelper::storeFile(
$approach,
new \SplFileInfo(\resource_path(
'../database/factories/assets/approaches/default-picture-100x100.png'
2024-04-12 12:15:18 +02:00
))
);
$approach->saveQuietly();
2024-04-12 12:15:18 +02:00
});
}
}