ldc-doux/database/factories/GammeFactory.php

41 lines
1.2 KiB
PHP
Raw Permalink Normal View History

2021-12-20 17:21:09 +01:00
<?php
namespace Database\Factories;
2022-01-23 15:03:05 +01:00
use App\Lib\Utils;
use App\Models\Gamme;
2021-12-20 17:21:09 +01:00
use Illuminate\Database\Eloquent\Factories\Factory;
use SplFileInfo;
2021-12-21 17:30:39 +01:00
use Illuminate\Support\Str;
2021-12-20 17:21:09 +01:00
class GammeFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
2026-10-27 09:12:51 +01:00
$title = $this->faker->text(10) . random_int(1, 100);
2021-12-21 17:30:39 +01:00
2022-08-11 12:34:27 +02:00
$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'));
2022-01-23 15:03:05 +01:00
$bannerpath = Utils::storeImage($upload, $picture->getTable());
2021-12-20 17:21:09 +01:00
return [
'parent_gamme_id' => null,
2021-12-21 17:30:39 +01:00
'title' => $title,
'slug' => Str::slug($title),
2021-12-20 17:21:09 +01:00
'text' => $this->faker->text(5),
'color' => $this->faker->hexColor(),
2022-01-23 15:03:05 +01:00
'picture' => $imgpath,
2021-12-20 17:21:09 +01:00
'alt_text_picture' => $this->faker->sentence(10),
2022-01-23 15:03:05 +01:00
'banner' => $bannerpath,
2021-12-20 17:21:09 +01:00
'alt_text_banner' => $this->faker->sentence(10),
];
}
}