make()->each(function (Section $section) use ($sectionEnum) { $section->section = $sectionEnum; $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( '../database/factories/assets/sections/home-missions-430x430.jpg' )) ), fake()->sentence(), fake()->sentence(), 430, 430, 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( '../database/factories/assets/sections/home-team-465x525.jpg' )) ), fake()->sentence(), fake()->sentence(), 465, 525, 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( [], \clean(\fake()->randomHtml()), fake()->sentence() ); } /** * Get MiniCrud datas for Commit - Living section. * * @param \App\Models\Section $section * @return array */ private function getCommitLivingData(\App\Models\Section $section) { return $section->getCommitLivingBloc( [], \clean(\fake()->randomHtml()), fake()->sentence() ); } /** * 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( [], \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, ); } /** * 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()) ); } /** * 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() ); } /** * Get MiniCrud datas for Move - Commitments section. * * @param \App\Models\Section $section * @return array */ private function getMoveCommitmentsData(\App\Models\Section $section) { return $section->getMoveCommitmentsBloc([]); } // * WE PRODUCE /** * Get MiniCrud datas for Produce - Linking section. * * @param \App\Models\Section $section * @return array */ private function getProduceLocalData(\App\Models\Section $section) { return $section->getProduceLocalBloc( [], \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, ); } /** * 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, ); } }