ldc-doux/database/factories/ProductFactory.php

141 lines
4.4 KiB
PHP
Raw Permalink Normal View History

2021-12-22 17:32:05 +01:00
<?php
namespace Database\Factories;
2022-01-23 14:52:07 +01:00
use App\Lib\Utils;
use App\Models\Product;
2021-12-22 17:32:05 +01:00
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
use SplFileInfo;
class ProductFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
2026-10-27 09:12:51 +01:00
$name = $this->faker->text(10) . random_int(1, 100);
$tabFour = [
2021-12-24 15:58:59 +01:00
'id' => 0,
'name' => 'Four',
'url' => '/assets/images/four.png',
'time' => '1h30mins.',
'temp' => '200°C',
'status' => true
2026-10-27 09:12:51 +01:00
];
$tabFriteuse = [
2021-12-24 15:58:59 +01:00
'id' => 1,
'name' => 'Friteuse',
'url' => '/assets/images/friteuse.png',
'time' => '15 minutes',
'temp' => '100°C',
'status' => true
2026-10-27 09:12:51 +01:00
];
$tabPoele = [
2021-12-24 15:58:59 +01:00
'id' => 2,
'name' => 'Poêle',
'url' => '/assets/images/poele.png',
2022-01-06 17:50:26 +01:00
'time' => '5 minutes sur chaque face',
'temp' => '100°C',
2021-12-24 15:58:59 +01:00
'status' => false
2026-10-27 09:12:51 +01:00
];
$tabCocotte = [
2021-12-24 15:58:59 +01:00
'id' => 3,
'name' => 'Cocotte',
'url' => '/assets/images/cocotte.png',
'time' => '3 h',
'temp' => '80°C',
'status' => true
2026-10-27 09:12:51 +01:00
];
$tabPlancha = [
2021-12-24 15:58:59 +01:00
'id' => 4,
'name' => 'Plancha',
'url' => '/assets/images/plancha.png',
2022-01-06 17:50:26 +01:00
'time' => '20mins',
'temp' => '130°C',
2021-12-24 15:58:59 +01:00
'status' => false
2026-10-27 09:12:51 +01:00
];
$tabBainMarie = [
2021-12-24 15:58:59 +01:00
'id' => 5,
'name' => 'Bain Marie',
'url' => '/assets/images/bainmarie.png',
2022-01-06 17:50:26 +01:00
'time' => '30 mins à 45 mins',
'temp' => '80°C',
2021-12-24 15:58:59 +01:00
'status' => false
2026-10-27 09:12:51 +01:00
];
$tabBarbecue = [
2021-12-24 15:58:59 +01:00
'id' => 6,
'name' => 'Barbecue',
'url' => '/assets/images/barbecue.png',
2022-01-06 17:50:26 +01:00
'time' => '30 minutes',
'temp' => '200°C',
2021-12-24 15:58:59 +01:00
'status' => false
2026-10-27 09:12:51 +01:00
];
$tabMicroOndes = [
2021-12-24 15:58:59 +01:00
'id' => 7,
'name' => 'Micro Ondes',
'url' => '/assets/images/microondes.png',
2022-01-06 17:50:26 +01:00
'time' => '3mins',
'temp' => '900 Watts',
2021-12-24 15:58:59 +01:00
'status' => false
2026-10-27 09:12:51 +01:00
];
$tabCasserole = [
'id' => 8,
'name' => 'Casserole',
'url' => '/assets/images/casserole.png',
'time' => '10mins',
'temp' => '90°C',
'status' => false
2026-10-27 09:12:51 +01:00
];
$tabPlusProduit1 = [
2021-12-24 15:58:59 +01:00
'id' => 0,
'name' => 'Lorem ipsum set doloris',
'url' => '/assets/images/sans-label.jpg',
2026-10-27 09:12:51 +01:00
];
$tabPlusProduit2 = [
2021-12-24 15:58:59 +01:00
'id' => 1,
'name' => 'Lorem ipsum set doloris',
'url' => '/assets/images/sans-label.jpg',
2026-10-27 09:12:51 +01:00
];
$tabPlusProduit3 = [
2021-12-24 15:58:59 +01:00
'id' => 2,
'name' => 'Lorem ipsum set doloris',
'url' => '/assets/images/sans-label.jpg',
2026-10-27 09:12:51 +01:00
];
2022-01-23 14:52:07 +01:00
2022-08-11 12:34:27 +02:00
$upload = new SplFileInfo(resource_path('assets/images/product_sample_01.png'));
2022-01-23 15:03:05 +01:00
$picture = new Product();
$imgpath = Utils::storeImage($upload, $picture->getTable());
2022-01-23 14:52:07 +01:00
2021-12-22 17:32:05 +01:00
return [
'name' => $name,
'slug' => Str::slug($name),
'description' => $this->faker->paragraph(),
2022-01-23 14:52:07 +01:00
'picture' => $imgpath,
2021-12-22 17:32:05 +01:00
'alt_text_picture' => $this->faker->sentence(10),
2021-12-24 15:58:59 +01:00
'pictos' => json_encode([
'four' => $tabFour,
'friteuse' => $tabFriteuse,
'poele' => $tabPoele,
'cocotte' => $tabCocotte,
'plancha' => $tabPlancha,
'bainmarie' => $tabBainMarie,
'barbecue' => $tabBarbecue,
'microondes' => $tabMicroOndes,
'casserole' => $tabCasserole
2021-12-24 15:58:59 +01:00
]),
'plusproduit' => json_encode([$tabPlusProduit1, $tabPlusProduit2, $tabPlusProduit3]),
2021-12-22 17:32:05 +01:00
'is_published' => true,
2026-10-27 09:12:51 +01:00
'is_on_top' => random_int(true, false),
'is_news' => random_int(true, false),
'is_food_service' => random_int(true, false),
'is_halal' => random_int(true, false),
2021-12-22 17:32:05 +01:00
'seo_title' => $this->faker->text(5),
'seo_description' => $this->faker->sentence(20),
];
}
}