2023-11-16 09:42:21 +01:00
|
|
|
<?php
|
|
|
|
|
|
2024-02-12 15:51:31 +01:00
|
|
|
namespace Database\Seeders\Development;
|
2023-11-16 09:42:21 +01:00
|
|
|
|
|
|
|
|
use App\Enums\Sections\PageSectionEnum;
|
|
|
|
|
use App\Enums\StaticPageType;
|
|
|
|
|
use App\Lib\Helpers\FileStorageHelper;
|
|
|
|
|
use App\Models\Section;
|
|
|
|
|
use App\Models\StaticPage;
|
|
|
|
|
use Illuminate\Database\Seeder;
|
|
|
|
|
use Illuminate\Support\Str;
|
|
|
|
|
|
2024-02-12 15:51:31 +01:00
|
|
|
/**
|
|
|
|
|
* FIXME: Definir les tailes d'images pour les sections
|
|
|
|
|
*
|
|
|
|
|
* @package Database\Seeders\Development
|
|
|
|
|
*/
|
2023-11-16 09:42:21 +01:00
|
|
|
class SectionSeeder extends Seeder
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Run the database seeds.
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function run()
|
|
|
|
|
{
|
|
|
|
|
FileStorageHelper::removeModelFiles(new Section());
|
|
|
|
|
|
|
|
|
|
foreach (PageSectionEnum::cases() as $sectionEnum) {
|
2024-02-12 15:51:31 +01:00
|
|
|
// @phpstan-ignore-next-line
|
2023-11-16 09:42:21 +01:00
|
|
|
Section::factory(1)->make()->each(function (Section $section) use ($sectionEnum) {
|
2024-02-12 15:51:31 +01:00
|
|
|
$section->section = $sectionEnum;
|
2023-11-16 09:42:21 +01:00
|
|
|
$section->page_id = $this->getPageId($sectionEnum);
|
|
|
|
|
if ($sectionEnum === PageSectionEnum::hire_grow) {
|
|
|
|
|
$section->text = '';
|
|
|
|
|
};
|
|
|
|
|
// Call function according to the enum name.
|
|
|
|
|
$section->data = \method_exists(self::class, sprintf('get%sData', Str::studly($sectionEnum->name))) ?
|
|
|
|
|
self::{sprintf('get%sData', Str::studly($sectionEnum->name))}($section) :
|
|
|
|
|
[];
|
|
|
|
|
$section->saveQuietly();
|
|
|
|
|
});
|
|
|
|
|
} //end foreach
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get PageId related to the section.
|
|
|
|
|
*
|
|
|
|
|
* @param \App\Enums\Sections\PageSectionEnum $sectionEnum
|
|
|
|
|
* @return integer
|
|
|
|
|
*/
|
|
|
|
|
private function getPageId(\App\Enums\Sections\PageSectionEnum $sectionEnum): int
|
|
|
|
|
{
|
|
|
|
|
return match ($sectionEnum) {
|
|
|
|
|
PageSectionEnum::home_ambition,
|
|
|
|
|
PageSectionEnum::home_life,
|
|
|
|
|
PageSectionEnum::home_missions,
|
|
|
|
|
PageSectionEnum::home_team => StaticPage::where('type', StaticPageType::home)->first()->id,
|
|
|
|
|
PageSectionEnum::unveil_pole,
|
|
|
|
|
PageSectionEnum::unveil_local,
|
|
|
|
|
PageSectionEnum::unveil_sites,
|
|
|
|
|
PageSectionEnum::unveil_history,
|
|
|
|
|
PageSectionEnum::unveil_commitments => StaticPage::where('type', StaticPageType::unveil)->first()->id,
|
|
|
|
|
PageSectionEnum::hire_life,
|
|
|
|
|
PageSectionEnum::hire_formation,
|
|
|
|
|
PageSectionEnum::hire_grow,
|
|
|
|
|
PageSectionEnum::hire_parity,
|
|
|
|
|
PageSectionEnum::hire_find => StaticPage::where('type', StaticPageType::we_hire)->first()->id,
|
|
|
|
|
PageSectionEnum::commit_ambition,
|
|
|
|
|
PageSectionEnum::commit_breeding,
|
|
|
|
|
PageSectionEnum::commit_living,
|
|
|
|
|
PageSectionEnum::commit_respect_earth,
|
|
|
|
|
PageSectionEnum::commit_feed,
|
|
|
|
|
PageSectionEnum::commit_commitments => StaticPage::where('type', StaticPageType::we_commit)->first()->id,
|
|
|
|
|
PageSectionEnum::move_life,
|
|
|
|
|
PageSectionEnum::move_commitments => StaticPage::where('type', StaticPageType::we_move)->first()->id,
|
|
|
|
|
PageSectionEnum::produce_local,
|
|
|
|
|
PageSectionEnum::produce_gms,
|
|
|
|
|
PageSectionEnum::produce_rhd,
|
|
|
|
|
PageSectionEnum::produce_export,
|
|
|
|
|
PageSectionEnum::produce_quality,
|
|
|
|
|
PageSectionEnum::produce_linking => StaticPage::where('type', StaticPageType::we_produce)->first()->id,
|
|
|
|
|
PageSectionEnum::listening_study => StaticPage::where('type', StaticPageType::we_listen)->first()->id,
|
|
|
|
|
}; //end match
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get MiniCrud datas for Home - Ambition section.
|
|
|
|
|
*
|
|
|
|
|
* @param \App\Models\Section $section
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
private function getHomeAmbitionData(\App\Models\Section $section)
|
|
|
|
|
{
|
|
|
|
|
return $section->getHomeAmbitionBloc([]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get MiniCrud datas for Home - Life section.
|
|
|
|
|
*
|
|
|
|
|
* @param \App\Models\Section $section
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
private function getHomeLifeData(\App\Models\Section $section)
|
|
|
|
|
{
|
|
|
|
|
return $section->getHomeLifeBloc([]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get MiniCrud datas for Home - Missions section.
|
|
|
|
|
*
|
|
|
|
|
* @param \App\Models\Section $section
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
private function getHomeMissionsData(\App\Models\Section $section)
|
|
|
|
|
{
|
|
|
|
|
return $section->getHomeMissionsBloc(
|
|
|
|
|
[],
|
|
|
|
|
FileStorageHelper::storeFile(
|
|
|
|
|
new Section(),
|
|
|
|
|
new \SplFileInfo(\resource_path(
|
2024-02-12 15:51:31 +01:00
|
|
|
'../database/factories/assets/sections/home-missions-430x430.jpg'
|
2023-11-16 09:42:21 +01:00
|
|
|
))
|
|
|
|
|
),
|
|
|
|
|
fake()->sentence(),
|
|
|
|
|
fake()->sentence(),
|
2024-02-12 15:51:31 +01:00
|
|
|
430,
|
|
|
|
|
430,
|
2023-11-16 09:42:21 +01:00
|
|
|
fake()->url(),
|
|
|
|
|
fake()->randomNumber(),
|
|
|
|
|
fake()->randomNumber()
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get MiniCrud datas for Home - Team section.
|
|
|
|
|
*
|
|
|
|
|
* @param \App\Models\Section $section
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
private function getHomeTeamData(\App\Models\Section $section)
|
|
|
|
|
{
|
|
|
|
|
return $section->getHomeTeamBloc(
|
|
|
|
|
[],
|
|
|
|
|
FileStorageHelper::storeFile(
|
|
|
|
|
new Section(),
|
|
|
|
|
new \SplFileInfo(\resource_path(
|
2024-02-12 15:51:31 +01:00
|
|
|
'../database/factories/assets/sections/home-team-465x525.jpg'
|
2023-11-16 09:42:21 +01:00
|
|
|
))
|
|
|
|
|
),
|
|
|
|
|
fake()->sentence(),
|
|
|
|
|
fake()->sentence(),
|
2024-02-12 15:51:31 +01:00
|
|
|
465,
|
|
|
|
|
525,
|
2023-11-16 09:42:21 +01:00
|
|
|
fake()->url(),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get MiniCrud datas for Unveil - Pole section.
|
|
|
|
|
*
|
|
|
|
|
* @param \App\Models\Section $section
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
private function getUnveilPoleData(\App\Models\Section $section)
|
|
|
|
|
{
|
|
|
|
|
return $section->getUnveilPoleBloc(
|
|
|
|
|
[],
|
|
|
|
|
fake()->randomNumber(),
|
|
|
|
|
fake()->randomNumber(),
|
|
|
|
|
fake()->randomNumber(),
|
|
|
|
|
fake()->randomNumber()
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get MiniCrud datas for Hire - Grow section.
|
|
|
|
|
*
|
|
|
|
|
* @param \App\Models\Section $section
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
private function getHireGrowData(\App\Models\Section $section)
|
|
|
|
|
{
|
|
|
|
|
return $section->getHireGrowBloc(
|
|
|
|
|
[],
|
|
|
|
|
fake()->text(35)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get MiniCrud datas for Hire - Parity section.
|
|
|
|
|
*
|
|
|
|
|
* @param \App\Models\Section $section
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
private function getHireParityData(\App\Models\Section $section)
|
|
|
|
|
{
|
|
|
|
|
return $section->getHireParityBloc(
|
|
|
|
|
[],
|
|
|
|
|
FileStorageHelper::storeFile(
|
|
|
|
|
new Section(),
|
|
|
|
|
new \SplFileInfo(\resource_path(
|
|
|
|
|
'../database/factories/assets/sections/default-picture-100x100.png'
|
|
|
|
|
))
|
|
|
|
|
),
|
|
|
|
|
fake()->sentence(),
|
|
|
|
|
fake()->sentence(),
|
|
|
|
|
100,
|
|
|
|
|
100,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get MiniCrud datas for Commit - Breeding section.
|
|
|
|
|
*
|
|
|
|
|
* @param \App\Models\Section $section
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
private function getCommitBreedingData(\App\Models\Section $section)
|
|
|
|
|
{
|
|
|
|
|
return $section->getCommitBreedingBloc(
|
|
|
|
|
[],
|
2024-03-13 12:20:44 +01:00
|
|
|
\clean(\fake()->randomHtml()),
|
|
|
|
|
fake()->sentence()
|
2023-11-16 09:42:21 +01:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get MiniCrud datas for Commit - Living section.
|
|
|
|
|
*
|
|
|
|
|
* @param \App\Models\Section $section
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
private function getCommitLivingData(\App\Models\Section $section)
|
|
|
|
|
{
|
|
|
|
|
return $section->getCommitLivingBloc(
|
|
|
|
|
[],
|
2024-03-13 12:20:44 +01:00
|
|
|
\clean(\fake()->randomHtml()),
|
|
|
|
|
fake()->sentence()
|
2023-11-16 09:42:21 +01:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get MiniCrud datas for Commit - Respect Earth section.
|
|
|
|
|
*
|
|
|
|
|
* @param \App\Models\Section $section
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
private function getCommitRespectEarthData(\App\Models\Section $section)
|
|
|
|
|
{
|
|
|
|
|
return $section->getCommitRespectEarthBloc(
|
|
|
|
|
[],
|
2024-03-13 12:20:44 +01:00
|
|
|
\clean(\fake()->randomHtml()),
|
|
|
|
|
FileStorageHelper::storeFile(
|
|
|
|
|
new Section(),
|
|
|
|
|
new \SplFileInfo(\resource_path(
|
|
|
|
|
'../database/factories/assets/sections/default-picture-100x100.png'
|
|
|
|
|
))
|
|
|
|
|
),
|
|
|
|
|
fake()->sentence(),
|
|
|
|
|
fake()->sentence(),
|
|
|
|
|
100,
|
|
|
|
|
100,
|
2023-11-16 09:42:21 +01:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get MiniCrud datas for Commit - Feed section.
|
|
|
|
|
*
|
|
|
|
|
* @param \App\Models\Section $section
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
private function getCommitFeedData(\App\Models\Section $section)
|
|
|
|
|
{
|
|
|
|
|
return $section->getCommitFeedBloc(
|
|
|
|
|
[],
|
|
|
|
|
\clean(\fake()->randomHtml()),
|
|
|
|
|
\clean(\fake()->randomHtml())
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-17 16:07:28 +01:00
|
|
|
/**
|
|
|
|
|
* Get MiniCrud datas for Commit - Commitments section.
|
|
|
|
|
*
|
|
|
|
|
* @param \App\Models\Section $section
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
private function getCommitCommitmentsData(\App\Models\Section $section)
|
|
|
|
|
{
|
|
|
|
|
return $section->getCommitCommitmentsBloc(
|
|
|
|
|
[],
|
|
|
|
|
fake()->sentence(),
|
|
|
|
|
fake()->sentence()
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-16 09:42:21 +01:00
|
|
|
/**
|
|
|
|
|
* Get MiniCrud datas for Move - Commitments section.
|
|
|
|
|
*
|
|
|
|
|
* @param \App\Models\Section $section
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
private function getMoveCommitmentsData(\App\Models\Section $section)
|
|
|
|
|
{
|
|
|
|
|
return $section->getMoveCommitmentsBloc([]);
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-14 15:25:04 +01:00
|
|
|
// * WE PRODUCE
|
|
|
|
|
|
2023-11-16 09:42:21 +01:00
|
|
|
/**
|
|
|
|
|
* Get MiniCrud datas for Produce - Linking section.
|
|
|
|
|
*
|
|
|
|
|
* @param \App\Models\Section $section
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
2024-03-14 15:25:04 +01:00
|
|
|
private function getProduceLocalData(\App\Models\Section $section)
|
2023-11-16 09:42:21 +01:00
|
|
|
{
|
2024-03-14 15:25:04 +01:00
|
|
|
return $section->getProduceLocalBloc(
|
2023-11-16 09:42:21 +01:00
|
|
|
[],
|
|
|
|
|
\clean(\fake()->randomHtml()),
|
2024-03-14 15:25:04 +01:00
|
|
|
FileStorageHelper::storeFile(
|
|
|
|
|
new Section(),
|
|
|
|
|
new \SplFileInfo(\resource_path(
|
|
|
|
|
'../database/factories/assets/sections/default-picture-100x100.png'
|
|
|
|
|
))
|
|
|
|
|
),
|
|
|
|
|
fake()->sentence(),
|
|
|
|
|
fake()->sentence(),
|
|
|
|
|
200,
|
|
|
|
|
200,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get MiniCrud datas for Produce - Linking section.
|
|
|
|
|
*
|
|
|
|
|
* @param \App\Models\Section $section
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
private function getProduceGmsData(\App\Models\Section $section)
|
|
|
|
|
{
|
|
|
|
|
return $section->getProduceGmsBloc(
|
|
|
|
|
[],
|
|
|
|
|
\clean(\fake()->randomHtml()),
|
|
|
|
|
FileStorageHelper::storeFile(
|
|
|
|
|
new Section(),
|
|
|
|
|
new \SplFileInfo(\resource_path(
|
|
|
|
|
'../database/factories/assets/sections/default-picture-100x100.png'
|
|
|
|
|
))
|
|
|
|
|
),
|
|
|
|
|
fake()->sentence(),
|
|
|
|
|
fake()->sentence(),
|
|
|
|
|
200,
|
|
|
|
|
200,
|
|
|
|
|
FileStorageHelper::storeFile(
|
|
|
|
|
new Section(),
|
|
|
|
|
new \SplFileInfo(\resource_path(
|
|
|
|
|
'../database/factories/assets/sections/produce-banner-1200x450.png'
|
|
|
|
|
))
|
|
|
|
|
),
|
|
|
|
|
1200,
|
|
|
|
|
450,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get MiniCrud datas for Produce - Linking section.
|
|
|
|
|
*
|
|
|
|
|
* @param \App\Models\Section $section
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
private function getProduceRhdData(\App\Models\Section $section)
|
|
|
|
|
{
|
|
|
|
|
return $section->getProduceRhdBloc(
|
|
|
|
|
[],
|
|
|
|
|
\clean(\fake()->randomHtml()),
|
|
|
|
|
FileStorageHelper::storeFile(
|
|
|
|
|
new Section(),
|
|
|
|
|
new \SplFileInfo(\resource_path(
|
|
|
|
|
'../database/factories/assets/sections/default-picture-100x100.png'
|
|
|
|
|
))
|
|
|
|
|
),
|
|
|
|
|
fake()->sentence(),
|
|
|
|
|
fake()->sentence(),
|
|
|
|
|
100,
|
|
|
|
|
100,
|
|
|
|
|
FileStorageHelper::storeFile(
|
|
|
|
|
new Section(),
|
|
|
|
|
new \SplFileInfo(\resource_path(
|
|
|
|
|
'../database/factories/assets/sections/produce-banner-1200x450.png'
|
|
|
|
|
))
|
|
|
|
|
),
|
|
|
|
|
1200,
|
|
|
|
|
450,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get MiniCrud datas for Produce - Linking section.
|
|
|
|
|
*
|
|
|
|
|
* @param \App\Models\Section $section
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
private function getProduceExportData(\App\Models\Section $section)
|
|
|
|
|
{
|
|
|
|
|
return $section->getProduceExportBloc(
|
|
|
|
|
[],
|
|
|
|
|
\clean(\fake()->randomHtml()),
|
|
|
|
|
FileStorageHelper::storeFile(
|
|
|
|
|
new Section(),
|
|
|
|
|
new \SplFileInfo(\resource_path(
|
|
|
|
|
'../database/factories/assets/sections/default-picture-100x100.png'
|
|
|
|
|
))
|
|
|
|
|
),
|
|
|
|
|
fake()->sentence(),
|
|
|
|
|
fake()->sentence(),
|
|
|
|
|
100,
|
|
|
|
|
100,
|
|
|
|
|
FileStorageHelper::storeFile(
|
|
|
|
|
new Section(),
|
|
|
|
|
new \SplFileInfo(\resource_path(
|
|
|
|
|
'../database/factories/assets/sections/produce-banner-1200x450.png'
|
|
|
|
|
))
|
|
|
|
|
),
|
|
|
|
|
1200,
|
|
|
|
|
450,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get MiniCrud datas for Produce - Linking section.
|
|
|
|
|
*
|
|
|
|
|
* @param \App\Models\Section $section
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
private function getProduceQualityData(\App\Models\Section $section)
|
|
|
|
|
{
|
|
|
|
|
return $section->getProduceQualityBloc(
|
|
|
|
|
[],
|
|
|
|
|
\clean(\fake()->randomHtml()),
|
|
|
|
|
FileStorageHelper::storeFile(
|
|
|
|
|
new Section(),
|
|
|
|
|
new \SplFileInfo(\resource_path(
|
|
|
|
|
'../database/factories/assets/sections/default-picture-100x100.png'
|
|
|
|
|
))
|
|
|
|
|
),
|
|
|
|
|
fake()->sentence(),
|
|
|
|
|
fake()->sentence(),
|
|
|
|
|
100,
|
|
|
|
|
100,
|
|
|
|
|
FileStorageHelper::storeFile(
|
|
|
|
|
new Section(),
|
|
|
|
|
new \SplFileInfo(\resource_path(
|
|
|
|
|
'../database/factories/assets/sections/produce-banner-1200x450.png'
|
|
|
|
|
))
|
|
|
|
|
),
|
|
|
|
|
1200,
|
|
|
|
|
450,
|
2023-11-16 09:42:21 +01:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|