ldc-legaulois/database/seeders/Mandatory/StaticPageSeeder.php
2026-09-25 16:25:31 +02:00

145 lines
6 KiB
PHP

<?php
namespace Database\Seeders\Mandatory;
use App\Enums\InputType;
use App\Enums\StaticPageType;
use App\Lib\Helpers\FileStorageHelper;
use App\Models\StaticPage;
use Illuminate\Database\Seeder;
class StaticPageSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$this->seedStaticPage(StaticPageType::home);
$this->seedStaticPage(StaticPageType::exitOutside);
$this->seedStaticPage(StaticPageType::ouiCBon);
$this->seedStaticPage(StaticPageType::tdf);
$this->seedStaticPage(StaticPageType::contact);
$this->seedStaticPage(StaticPageType::legals);
$this->seedStaticPage(StaticPageType::confidentiality);
$this->seedStaticPage(StaticPageType::selling);
$this->seedStaticPage(StaticPageType::recruitment);
$this->seedStaticPage(StaticPageType::story);
$this->seedStaticPage(StaticPageType::saga);
$this->seedStaticPage(StaticPageType::recipes);
$this->seedStaticPage(StaticPageType::accessibility);
$this->seedStaticPage(StaticPageType::breedingFood);
$this->seedStaticPage(StaticPageType::breedingHealth);
$this->seedStaticPage(StaticPageType::breedingJob);
$this->seedStaticPage(StaticPageType::breedingPoultry);
$this->seedStaticPage(StaticPageType::news);
$this->seedStaticPage(StaticPageType::recipe, [
'tips_title' => [
'label' => 'Titre de l\'astuce',
'inputType' => InputType::string->value,
'value' => fake()->sentence(),
'validate' => 'required|string|between:3,255',
'required' => true,
],
'recipes_title' => [
'label' => 'Titre des autres recettes',
'inputType' => InputType::string->value,
'value' => fake()->sentence(),
'validate' => 'required|string|between:3,255',
'required' => true,
],
'text' => [
'label' => 'Texte des autres recettes',
'inputType' => InputType::text->value,
'value' => fake()->sentence(),
'validate' => 'required|string',
'required' => true,
],
]);
$this->seedStaticPage(StaticPageType::products);
$this->seedStaticPage(StaticPageType::product, [
'claim_title' => [
'label' => 'Titre des allégations',
'inputType' => InputType::string->value,
'value' => fake()->sentence(),
'validate' => 'required|string|between:3,255',
'required' => true,
],
'recipes_title' => [
'label' => 'Titre des recettes',
'inputType' => InputType::string->value,
'value' => fake()->sentence(),
'validate' => 'required|string|between:3,255',
'required' => true,
],
'recipes_text' => [
'label' => 'Texte des recettes',
'inputType' => InputType::text->value,
'value' => fake()->sentence(),
'validate' => 'required|string',
'required' => true,
],
'products_title' => [
'label' => 'Titre des produits',
'inputType' => InputType::string->value,
'value' => fake()->sentence(),
'validate' => 'required|string|between:3,255',
'required' => true,
],
'products_text' => [
'label' => 'Texte des produits',
'inputType' => InputType::text->value,
'value' => fake()->sentence(),
'validate' => 'required|string',
'required' => true,
],
'animation_text_1' => [
'label' => 'Texte de l\'animation 1',
'inputType' => InputType::string->value,
'value' => fake()->sentence(),
'validate' => 'required|string|between:3,255',
'required' => true,
],
'animation_text_2' => [
'label' => 'Texte de l\'animation 2',
'inputType' => InputType::string->value,
'value' => fake()->sentence(),
'validate' => 'required|string|between:3,255',
'required' => true,
],
]);
$this->seedStaticPage(StaticPageType::search);
$this->seedStaticPage(StaticPageType::sitemap);
$this->seedStaticPage(StaticPageType::rules);
$this->seedStaticPage(StaticPageType::ourFarms);
}
/**
* Seed static page type
*/
private function seedStaticPage(StaticPageType $type, array $data = []): void
{
$staticPage = new StaticPage(
['type' => $type],
[
'type' => $type,
'seo_title' => sprintf('Seo title pour la page %s', $type->label()),
'seo_description' => sprintf('Seo description pour la page %s', $type->label()),
'title' => $type->label(),
'subtitle' => 'sous-titre' . $type->label(),
'picture_alt' => 'picture alt',
'picture_title' => 'picture title',
'picture' => FileStorageHelper::storeFile(
(new StaticPage()),
new \SplFileInfo(\resource_path(
'../database/factories/assets/static_pages/default-picture-720x405.jpg'
))
),
'content' => \clean(\fake()->randomHtml()),
'data' => $data,
]
);
$staticPage->slug = str($type->label())->slug();
$staticPage->saveQuietly();
}
}