ldc-doux/database/factories/PictoFactory.php
2022-08-11 12:34:27 +02:00

36 lines
803 B
PHP

<?php
namespace Database\Factories;
use App\Lib\Utils;
use App\Models\Picto;
use Illuminate\Database\Eloquent\Factories\Factory;
use SplFileInfo;
class PictoFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Picto::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
$upload = new SplFileInfo(resource_path('assets/images/qualite.png'));
$picto = new Picto();
$imgpath = Utils::storeImage($upload, $picto->getTable());
return [
'picture' => $imgpath,
'alt_text_picture' => $this->faker->sentence(10),
'text' => $this->faker->text(10),
];
}
}