ldc-doux/database/factories/GammeFactory.php
2022-01-23 15:03:05 +01:00

40 lines
1.1 KiB
PHP

<?php
namespace Database\Factories;
use App\Lib\Utils;
use App\Models\Gamme;
use Illuminate\Database\Eloquent\Factories\Factory;
use SplFileInfo;
use Illuminate\Support\Str;
class GammeFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
$title = $this->faker->text(10) . rand(1, 100);
$upload = new SplFileInfo(resource_path('assets/images/cookrange.jpg'));
$picture = new Gamme();
$imgpath = Utils::storeImage($upload, $picture->getTable());
$upload = new SplFileInfo(resource_path('assets/images/entete_sous_gammes.jpg'));
$bannerpath = Utils::storeImage($upload, $picture->getTable());
return [
'parent_gamme_id' => null,
'title' => $title,
'slug' => Str::slug($title),
'text' => $this->faker->text(5),
'color' => $this->faker->hexColor(),
'picture' => $imgpath,
'alt_text_picture' => $this->faker->sentence(10),
'banner' => $bannerpath,
'alt_text_banner' => $this->faker->sentence(10),
];
}
}