From b56914f9e9fdf1df5cecc185d271700cb0b980f2 Mon Sep 17 00:00:00 2001 From: Noah Lancien Date: Thu, 16 Nov 2023 09:42:21 +0100 Subject: [PATCH] Added seeders and factories --- app/Enums/Sections/PageSectionEnum.php | 75 +++ app/Enums/Sites/SpeciesEnum.php | 31 ++ app/Enums/Slides/SliderTypeEnum.php | 23 + app/Enums/StaticPageType.php | 14 + app/Enums/Strips/PictoEnum.php | 29 + app/Enums/Testimonials/TypeEnum.php | 29 + .../StaticPages/UpdateStaticPageRequest.php | 2 +- app/Lib/Helpers/FileStorageHelper.php | 20 +- app/Models/ActivityLog.php | 2 +- app/Models/HistoricalMilestone.php | 89 +++ app/Models/JobVideo.php | 29 + app/Models/Logo.php | 80 +++ app/Models/News.php | 203 +++++++ app/Models/Section.php | 525 ++++++++++++++++++ app/Models/Site.php | 244 ++++++++ app/Models/Slide.php | 91 +++ app/Models/StaticPage.php | 15 +- app/Models/Strip.php | 138 +++++ app/Models/Testimonial.php | 82 +++ app/Models/User.php | 4 +- .../factories/HistoricalMilestoneFactory.php | 28 + database/factories/JobVideoFactory.php | 22 + database/factories/LogoFactory.php | 21 + database/factories/NewsFactory.php | 40 ++ database/factories/SectionFactory.php | 21 + database/factories/SiteFactory.php | 56 ++ database/factories/SlideFactory.php | 27 + database/factories/StripFactory.php | 31 ++ database/factories/TestimonialFactory.php | 26 + .../default-picture-100x100.png | Bin 0 -> 581 bytes .../assets/logos/default-picture-100x100.png | Bin 0 -> 581 bytes .../assets/news/default-picture-100x100.png | Bin 0 -> 581 bytes .../sections/default-picture-100x100.png | Bin 0 -> 581 bytes .../assets/sites/default-picture-100x100.png | Bin 0 -> 581 bytes .../assets/slides/default-picture-100x100.png | Bin 0 -> 581 bytes .../testimonials/default-picture-100x100.png | Bin 0 -> 581 bytes .../2023_11_14_142558_create_news_table.php | 3 +- ...023_11_14_142558_create_sections_table.php | 2 +- .../2023_11_14_142558_create_sites_table.php | 2 +- .../2023_11_14_142558_create_slides_table.php | 4 +- database/seeders/DatabaseSeeder.php | 9 + .../seeders/HistoricalMilestoneSeeder.php | 29 + database/seeders/JobVideoSeeder.php | 19 + database/seeders/LogoSeeder.php | 29 + database/seeders/NewsSeeder.php | 35 ++ database/seeders/SectionSeeder.php | 298 ++++++++++ database/seeders/SiteSeeder.php | 53 ++ database/seeders/SlideSeeder.php | 34 ++ database/seeders/StaticPageSeeder.php | 172 ++++-- database/seeders/StripSeeder.php | 21 + database/seeders/TestimonialSeeder.php | 33 ++ 51 files changed, 2686 insertions(+), 54 deletions(-) create mode 100644 app/Enums/Sections/PageSectionEnum.php create mode 100644 app/Enums/Sites/SpeciesEnum.php create mode 100644 app/Enums/Slides/SliderTypeEnum.php create mode 100644 app/Enums/Strips/PictoEnum.php create mode 100644 app/Enums/Testimonials/TypeEnum.php create mode 100644 app/Models/HistoricalMilestone.php create mode 100644 app/Models/JobVideo.php create mode 100644 app/Models/Logo.php create mode 100644 app/Models/News.php create mode 100644 app/Models/Section.php create mode 100644 app/Models/Site.php create mode 100644 app/Models/Slide.php create mode 100644 app/Models/Strip.php create mode 100644 app/Models/Testimonial.php create mode 100644 database/factories/HistoricalMilestoneFactory.php create mode 100644 database/factories/JobVideoFactory.php create mode 100644 database/factories/LogoFactory.php create mode 100644 database/factories/NewsFactory.php create mode 100644 database/factories/SectionFactory.php create mode 100644 database/factories/SiteFactory.php create mode 100644 database/factories/SlideFactory.php create mode 100644 database/factories/StripFactory.php create mode 100644 database/factories/TestimonialFactory.php create mode 100644 database/factories/assets/historical_milestones/default-picture-100x100.png create mode 100644 database/factories/assets/logos/default-picture-100x100.png create mode 100644 database/factories/assets/news/default-picture-100x100.png create mode 100644 database/factories/assets/sections/default-picture-100x100.png create mode 100644 database/factories/assets/sites/default-picture-100x100.png create mode 100644 database/factories/assets/slides/default-picture-100x100.png create mode 100644 database/factories/assets/testimonials/default-picture-100x100.png create mode 100644 database/seeders/HistoricalMilestoneSeeder.php create mode 100644 database/seeders/JobVideoSeeder.php create mode 100644 database/seeders/LogoSeeder.php create mode 100644 database/seeders/NewsSeeder.php create mode 100644 database/seeders/SectionSeeder.php create mode 100644 database/seeders/SiteSeeder.php create mode 100644 database/seeders/SlideSeeder.php create mode 100644 database/seeders/StripSeeder.php create mode 100644 database/seeders/TestimonialSeeder.php diff --git a/app/Enums/Sections/PageSectionEnum.php b/app/Enums/Sections/PageSectionEnum.php new file mode 100644 index 0000000..a05d00c --- /dev/null +++ b/app/Enums/Sections/PageSectionEnum.php @@ -0,0 +1,75 @@ +name => 'Nos Missions', + self::home_ambition->name => 'Notre Ambition', + self::home_team->name => 'L\'équipe VOLENA', + self::home_life->name => 'La vie chez VOLENA', + self::unveil_pole->name => 'Le Pôle Volena', + self::unveil_local->name => 'Notre Filière Locale', + self::unveil_sites->name => 'Nos Sites', + self::unveil_history->name => 'Histoire', + self::unveil_commitments->name => 'Engagements', + self::hire_life->name => 'Vie de l\'entreprise', + self::hire_formation->name => 'Alternance et formation', + self::hire_grow->name => 'Fiers d\'évoluer ensemble', + self::hire_parity->name => 'Parité', + self::hire_find->name => 'On se retrouve', + self::commit_ambition->name => 'Ambition', + self::commit_breeding->name => 'Elever Durablement', + self::commit_living->name => 'Mieux vivre', + self::commit_respect_earth->name => 'Respecter la terre', + self::commit_feed->name => 'Bien nourrir', + self::commit_commitments->name => 'Engagements', + self::move_life->name => 'vie de l\'entreprise', + self::move_commitments->name => 'engagements', + self::produce_local->name => 'large gamme locale', + self::produce_gms->name => 'Retrouvez en GMS', + self::produce_rhd->name => 'RHD', + self::produce_export->name => 'Export', + self::produce_quality->name => 'Qualité', + self::produce_linking->name => 'Qualité', + self::listening_study->name => 'On étudie', + ]; +} diff --git a/app/Enums/Sites/SpeciesEnum.php b/app/Enums/Sites/SpeciesEnum.php new file mode 100644 index 0000000..9454260 --- /dev/null +++ b/app/Enums/Sites/SpeciesEnum.php @@ -0,0 +1,31 @@ +name => 'Poulet', + self::turkey->name => 'Dinde', + self::hen->name => 'Poule', + self::duck->name => 'Canard', + self::rabbit->name => 'Lapin', + self::guinea_fowl->name => 'Pintade', + self::rooster->name => 'Coq', + ]; +} diff --git a/app/Enums/Slides/SliderTypeEnum.php b/app/Enums/Slides/SliderTypeEnum.php new file mode 100644 index 0000000..c01556d --- /dev/null +++ b/app/Enums/Slides/SliderTypeEnum.php @@ -0,0 +1,23 @@ +name => 'Accueil', + self::better_life->name => 'Mieux vivre', + self::respect_earth->name => 'Respecter la terre', + ]; +} diff --git a/app/Enums/StaticPageType.php b/app/Enums/StaticPageType.php index 060203b..93ad19f 100644 --- a/app/Enums/StaticPageType.php +++ b/app/Enums/StaticPageType.php @@ -11,6 +11,13 @@ enum StaticPageType: int case contact = 1; case legals = 2; case confidentiality = 3; + case home = 4; + case unveil = 5; + case we_hire = 6; + case we_commit = 7; + case we_move = 8; + case we_produce = 9; + case we_listen = 10; /** * Optionnal labels definition. @@ -19,5 +26,12 @@ enum StaticPageType: int self::contact->name => 'Contact', self::legals->name => 'Mentions légales', self::confidentiality->name => 'Confidentialité', + self::home->name => 'Accueil', + self::unveil->name => 'On se Dévoile', + self::we_hire->name => 'On Embauche', + self::we_commit->name => 'On s\'Engage', + self::we_move->name => 'On Bouge Ensemble', + self::we_produce->name => 'On Produit', + self::we_listen->name => 'On Vous Ecoute', ]; } diff --git a/app/Enums/Strips/PictoEnum.php b/app/Enums/Strips/PictoEnum.php new file mode 100644 index 0000000..2b8f588 --- /dev/null +++ b/app/Enums/Strips/PictoEnum.php @@ -0,0 +1,29 @@ +name => 'Danger', + self::respect_earth->name => 'Respecter la terre', + self::breeding->name => 'Elever Durablement', + self::feed->name => 'Bien Nourrir', + self::better_life->name => 'Mieux vivre en équipe', + self::none->name => 'Aucun', + ]; +} diff --git a/app/Enums/Testimonials/TypeEnum.php b/app/Enums/Testimonials/TypeEnum.php new file mode 100644 index 0000000..e12459d --- /dev/null +++ b/app/Enums/Testimonials/TypeEnum.php @@ -0,0 +1,29 @@ +name => 'Elever Durablement', + self::better_life->name => 'Mieux vivre en équipe', + self::respect_earth->name => 'Respecter la terre', + self::feed->name => 'Bien Nourrir', + self::volena->name => 'Voléna', + self::hire->name => 'On Embauche', + ]; +} diff --git a/app/Http/Requests/Bo/StaticPages/UpdateStaticPageRequest.php b/app/Http/Requests/Bo/StaticPages/UpdateStaticPageRequest.php index 238721f..c6238ed 100644 --- a/app/Http/Requests/Bo/StaticPages/UpdateStaticPageRequest.php +++ b/app/Http/Requests/Bo/StaticPages/UpdateStaticPageRequest.php @@ -25,7 +25,7 @@ class UpdateStaticPageRequest extends FormRequest public function prepareForValidation(): void { $this->merge([ - 'content' => (string)Str::of($this->content) + 'content' => (string)Str::of($this->post('content')) ]); } diff --git a/app/Lib/Helpers/FileStorageHelper.php b/app/Lib/Helpers/FileStorageHelper.php index 45ccec9..937b8db 100644 --- a/app/Lib/Helpers/FileStorageHelper.php +++ b/app/Lib/Helpers/FileStorageHelper.php @@ -118,7 +118,7 @@ class FileStorageHelper ); return str_replace('/private/', '', $newPath); - }//end if + } //end if if (\is_object($file) and $file instanceof \SplFileInfo) { /** @var \SplFileInfo $file */ $filename = $filename ?: $file->getBaseName(); @@ -451,4 +451,22 @@ class FileStorageHelper $filename = trim($filename, '.-'); return $filename; } + + /** + * Remove all model files for the given Model. + * + * @param Model $model + * @return void + */ + public static function removeModelFiles(Model $model): void + { + $tableName = $model::query()->getModel()->getTable(); + + if (!empty(Storage::disk('public')->allFiles("modelfiles/{$tableName}"))) { + Storage::disk('public')->deleteDirectory("modelfiles/{$tableName}"); + } + if (!empty(Storage::disk('private')->allFiles("modelfiles/{$tableName}"))) { + Storage::disk('private')->deleteDirectory("modelfiles/{$tableName}"); + } + } } diff --git a/app/Models/ActivityLog.php b/app/Models/ActivityLog.php index 1ab7000..62cad9b 100644 --- a/app/Models/ActivityLog.php +++ b/app/Models/ActivityLog.php @@ -14,7 +14,7 @@ use Illuminate\Support\Facades\Schema; * @property string $model_id Id of the target model. * @property string $event Event of this activity (ActivityLogsEventEnum). * @property string $data Changes. - * @property-read \Illuminate\Support\Carbon $created_at Created date. + * @property-read \Carbon\Carbon $created_at Created date. * * @property-read \App\Models\User $user User BelongsTo relation. */ diff --git a/app/Models/HistoricalMilestone.php b/app/Models/HistoricalMilestone.php new file mode 100644 index 0000000..2872194 --- /dev/null +++ b/app/Models/HistoricalMilestone.php @@ -0,0 +1,89 @@ + + */ + protected $fillable = [ + 'title', + 'text', + 'picture', + 'picture_alt', + 'picture_title', + 'button_status', + 'button_label', + 'button_url', + 'button_new_tab', + 'year', + ]; + + /** + * The attributes that should be cast. + * + * @var array + */ + protected $casts = [ + 'button_status' => 'boolean', + 'button_new_tab' => 'boolean', + ]; + + /** + * Perform any actions required after the model boots. + * + * @return void + */ + protected static function booted(): void + { + static::creating(function (self $model) { + self::manageFields($model); + }); + static::updating(function (self $model) { + self::manageFields($model); + }); + static::updated(function (self $model) { + FileStorageHelper::removeOldFile($model, 'picture'); + }); + + static::deleted(function (self $model) { + FileStorageHelper::removeFile($model, 'picture'); + }); + } + + // * METHODS + + /** + * Manage model fields. + * + * @param self $model + * @return void + */ + private static function manageFields(self $model): void + { + $model->picture = FileStorageHelper::storeFile($model, $model->picture, true); + } +} diff --git a/app/Models/JobVideo.php b/app/Models/JobVideo.php new file mode 100644 index 0000000..fe8e7c3 --- /dev/null +++ b/app/Models/JobVideo.php @@ -0,0 +1,29 @@ + + */ + protected $fillable = [ + 'title', + 'place', + 'video_id', + ]; +} diff --git a/app/Models/Logo.php b/app/Models/Logo.php new file mode 100644 index 0000000..62e84a2 --- /dev/null +++ b/app/Models/Logo.php @@ -0,0 +1,80 @@ + + */ + protected $fillable = [ + 'picture', + 'picture_alt', + 'picture_title', + ]; + + /** + * Perform any actions required after the model boots. + * + * @return void + */ + protected static function booted(): void + { + static::creating(function (self $model) { + self::manageFields($model); + }); + static::updating(function (self $model) { + self::manageFields($model); + }); + static::updated(function (self $model) { + FileStorageHelper::removeOldFile($model, 'picture'); + }); + + static::deleted(function (self $model) { + FileStorageHelper::removeFile($model, 'picture'); + }); + } + + // * METHODS + + /** + * Manage model fields. + * + * @param self $model + * @return void + */ + private static function manageFields(self $model): void + { + $model->picture = FileStorageHelper::storeFile($model, $model->picture, true); + } + + // * RELATIONS + + /** + * The sites that belong to the logo. + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + */ + public function sites(): \Illuminate\Database\Eloquent\Relations\BelongsToMany + { + return $this->belongsToMany(Site::class); + } +} diff --git a/app/Models/News.php b/app/Models/News.php new file mode 100644 index 0000000..e6e2e72 --- /dev/null +++ b/app/Models/News.php @@ -0,0 +1,203 @@ + + */ + protected $fillable = [ + 'seo_title', + 'seo_description', + 'title', + 'slug', + 'introduction', + 'content', + 'linkedin_url', + 'thumbnail', + 'thumbnail_alt', + 'thumbnail_title', + 'picture', + 'picture_alt', + 'picture_title', + 'order', + 'published', + 'publish_at', + 'unpublish_at', + ]; + + /** + * The attributes that should be cast. + * + * @var array + */ + protected $casts = [ + 'published' => 'bool', + 'publish_at' => 'datetime', + 'unpublish_at' => 'datetime', + ]; + + /** + * Perform any actions required after the model boots. + * + * @return void + */ + protected static function booted(): void + { + static::creating(function (self $model) { + self::setOrder($model); + self::manageFields($model); + }); + static::updating(function (self $model) { + self::manageFields($model); + }); + static::updated(function (self $model) { + FileStorageHelper::removeOldFile($model, 'picture'); + }); + + static::deleted(function (self $model) { + FileStorageHelper::removeFile($model, 'picture'); + }); + } + + // * METHODS + + /** + * Manage model fields. + * + * @param self $model + * @return void + */ + private static function manageFields(self $model): void + { + // * ASSERTIONS + self::assertFieldIsUnique('title', $model->title); + self::assertFieldIsUnique('slug', Str::slug($model->title)); + + // * TRANSFORMATIONS + self::setSlug($model, $model->title); + self::makeStatusSense($model); + $model->picture = FileStorageHelper::storeFile($model, $model->picture, true); + $model->thumbnail = FileStorageHelper::storeFile($model, $model->thumbnail, true); + } + + /** + * Set the slug. + * + * @param self $model + * @param string $original + * + * @return void + */ + private static function setSlug(self $model, string $original): void + { + $model->slug = Str::slug($original); + } + + /** + * Set order after the last element of the list. + * + * @param self $model + * @return void + */ + private static function setOrder(self $model): void + { + $model->order = \intval(self::query()->max('order')) + 1; + } + + /** + * Asserts using validation that the field is unique. + * + * @param string $nameField + * @param string $valueField + * @param integer|null $id + * @return void + */ + private static function assertFieldIsUnique(string $nameField, string $valueField, ?int $id = null): void + { + $table = (new self())->getTable(); + ToolboxHelper::assertFieldIsUnique($table, $nameField, $valueField, $id); + } + + /** + * Adjusts model status using current status and publish dates + * + * @param self $model + * @return void + */ + private static function makeStatusSense(self $model): void + { + /** @var \Carbon\Carbon|null */ + $publish_at = $model->publish_at; + /** @var \Carbon\Carbon|null */ + $unpublish_at = $model->unpublish_at; + $wantedStatus = $model->published; + if ($publish_at or $unpublish_at) { + $model->published = $model->planificated_status; + } + if ($wantedStatus !== $model->published) { + $previousMessage = session()->get('bo.info', ''); + session()->flash('bo.info', \trans( + 'La publication est modifiée en concordance avec les dates enregistrées. + Pour modifier l\'état de publication, veuillez modifier ou enlever les dates correspondantes.' + ) . " \n{$previousMessage}"); + } + } + + /** + * Getter the current status following planification dates planificated_status + * + * @return boolean + */ + public function getPlanificatedStatusAttribute(): bool + { + /** @var \Carbon\Carbon|null */ + $publish_at = $this->publish_at; + /** @var \Carbon\Carbon|null */ + $unpublish_at = $this->unpublish_at; + if ($publish_at and $unpublish_at) { + return $unpublish_at->greaterThanOrEqualTo(now()) and $publish_at->lessThan(now()); + } + if ($publish_at) { + return $publish_at->lessThan(now()); + } + if ($unpublish_at) { + return $unpublish_at->greaterThanOrEqualTo(now()); + } + return false; + } +} diff --git a/app/Models/Section.php b/app/Models/Section.php new file mode 100644 index 0000000..d741105 --- /dev/null +++ b/app/Models/Section.php @@ -0,0 +1,525 @@ + + */ + protected $fillable = [ + 'section', + 'h2_title', + 'text', + 'data', + ]; + + /** + * The attributes that should be cast. + * + * @var array + */ + protected $casts = [ + 'section' => \App\Enums\Sections\PageSectionEnum::class, + 'data' => 'object', + ]; + + /** + * Perform any actions required after the model boots. + * + * @return void + */ + protected static function booted(): void + { + static::creating(function () { + throw new \RuntimeException("Creating a new section is not authorized"); + }); + static::updating(function (self $model) { + // * ASSERTIONS + ToolboxHelper::assertNoInternalBoUrls('data', $model->data); + + // * TRANSFORMATIONS + $model->data = FileStorageHelper::storeModelFilesFromHtml($model, $model->data); + }); + static::updated(function (self $model) { + FileStorageHelper::removeOldModelFilesFromHtml( + $model->data, + ToolboxHelper::getOriginal($model, 'data') + ); + }); + static::deleting(function () { + throw new \RuntimeException('Deleting a section is not authorized'); + }); + } + + // * METHODS + + /** + * Manage model fields. + * + * @param self $model + * @return void + */ + private static function manageFields(self $model): void + { + $model->picture = FileStorageHelper::storeFile($model, $model->picture, true); + } + + /** + * Get MiniCrud bloc for home_missions section. + * + * @param array $data + * @param string $img + * @param string $imgAlt + * @param string $imgTitle + * @param integer $width + * @param integer $height + * @param string $url + * @param integer $keyValueSites + * @param integer $keyValueJobs + * @return array + */ + public static function getHomeMissionsBloc( + array $data, + string $img, + string $imgAlt, + string $imgTitle, + int $width, + int $height, + string $url, + int $keyValueSites, + int $keyValueJobs + ): array { + $data = self::emptyPictureBloc($data, $img, $imgAlt, $imgTitle, $width, $height); + $data = self::emptyPictureLinkBloc($data, $url); + $data = self::emptyKeyNumberBloc($data, 'sites', $keyValueSites); + $data = self::emptyKeyNumberBloc($data, 'métiers', $keyValueJobs); + + return $data; + } + + /** + * Get MiniCrud bloc for home_ambition section. + * + * @param array $data + * @return array + */ + public static function getHomeAmbitionBloc(array $data): array + { + return self::emptyButtonBooleanBloc($data, 'On se Dévoile'); + } + + /** + * Get MiniCrud bloc for home_team section. + * + * @param array $data + * @param string $img + * @param string $imgAlt + * @param string $imgTitle + * @param integer $width + * @param integer $height + * @param string $url + * @return array + */ + public static function getHomeTeamBloc( + array $data, + string $img, + string $imgAlt, + string $imgTitle, + int $width, + int $height, + string $url + ): array { + $data = self::emptyPictureBloc($data, $img, $imgAlt, $imgTitle, $width, $height); + $data = self::emptyPictureLinkBloc($data, $url); + $data = self::emptyButtonBooleanBloc($data, 'On Embauche'); + + return $data; + } + + /** + * Get MiniCrud bloc for home_life section. + * + * @param array $data + * @return array + */ + public static function getHomeLifeBloc(array $data): array + { + return self::emptyButtonBooleanBloc($data, 'On Embauche'); + } + + /** + * Get MiniCrud bloc for unveil_pole section. + * + * @param array $data + * @param integer $keyValueSites + * @param integer $keyValueSpecies + * @param integer $keyValueCa + * @param integer $keyValueEmployees + * @return array + */ + public static function getUnveilPoleBloc( + array $data, + int $keyValueSites, + int $keyValueSpecies, + int $keyValueCa, + int $keyValueEmployees + ): array { + $data = self::emptyKeyNumberBloc($data, 'sites', $keyValueSites); + $data = self::emptyKeyNumberBloc($data, 'espèces', $keyValueSpecies); + $data = self::emptyKeyNumberBloc($data, 'ca', $keyValueCa); + $data = self::emptyKeyNumberBloc($data, 'collaborateurs', $keyValueEmployees); + + return $data; + } + + /** + * Get MiniCrud bloc for hire_grow section. + * + * @param array $data + * @param string $title + * @return array + */ + public static function getHireGrowBloc(array $data, string $title): array + { + return self::emptyH3Bloc($data, PageSectionEnum::hire_grow->label(), $title); + } + + /** + * Get MiniCrud bloc for hire_parity section. + * + * @param array $data + * @param string $img + * @param string $imgAlt + * @param string $imgTitle + * @param integer $width + * @param integer $height + * @return array + */ + public static function getHireParityBloc( + array $data, + string $img, + string $imgAlt, + string $imgTitle, + int $width, + int $height + ): array { + $data = self::emptyButtonBooleanBloc($data, 'On Bouge Ensemble'); + $data = self::emptyPictureBloc($data, $img, $imgAlt, $imgTitle, $width, $height, true); + + return $data; + } + + /** + * Get MiniCrud bloc for commit_breeding section. + * + * @param array $data + * @param string $img + * @param string $imgAlt + * @param string $imgTitle + * @param integer $width + * @param integer $height + * @return array + */ + public static function getCommitBreedingBloc( + array $data, + string $img, + string $imgAlt, + string $imgTitle, + int $width, + int $height + ): array { + $data = self::emptyButtonBooleanBloc($data, 'On Témoigne - engagements'); + $data = self::emptyPictureBloc($data, $img, $imgAlt, $imgTitle, $width, $height, true); + + return $data; + } + + /** + * Get MiniCrud bloc for commit_living section. + * + * @param array $data + * @param string $content + * @return array + */ + public static function getCommitLivingBloc(array $data, string $content): array + { + $data = self::emptyButtonBooleanBloc($data, 'On Témoigne - engagements'); + $data = self::emptyWysiwygBloc($data, 'second', $content, true); + $data = self::emptyButtonBooleanBloc($data, 'On Bouge'); + + return $data; + } + + /** + * Get MiniCrud bloc for commit_respect_earth section. + * + * @param array $data + * @param string $content + * @return array + */ + public static function getCommitRespectEarthBloc(array $data, string $content): array + { + $data = self::emptyButtonBooleanBloc($data, 'On Témoigne - engagements'); + $data = self::emptyWysiwygBloc($data, 'second', $content, true); + + return $data; + } + + /** + * Get MiniCrud bloc for commit_feed section. + * + * @param array $data + * @param string $content + * @param string $secondContent + * @return array + */ + public static function getCommitFeedBloc(array $data, string $content, string $secondContent): array + { + $data = self::emptyButtonBooleanBloc($data, 'On Témoigne - engagements'); + $data = self::emptyWysiwygBloc($data, 'second', $content, true); + $data = self::emptyButtonBooleanBloc($data, 'On Produit'); + $data = self::emptyWysiwygBloc($data, 'third', $secondContent, true); + + return $data; + } + + /** + * Get MiniCrud bloc for commit_commitments section. + * + * @param array $data + * @param string $firstTitle + * @param string $secondTitle + * @return array + */ + public static function getCommitCommitmentsBloc(array $data, string $firstTitle, string $secondTitle): array + { + $data = self::emptyH3Bloc($data, 'Premier', $firstTitle); + $data = self::emptyH3Bloc($data, 'Second', $secondTitle); + + return $data; + } + + /** + * Get MiniCrud bloc for move_commitments section. + * + * @param array $data + * @return array + */ + public static function getMoveCommitmentsBloc(array $data): array + { + return self::emptyButtonBooleanBloc($data, 'On Témoigne - engagements'); + } + + /** + * Get MiniCrud bloc for produce_linking section. + * + * @param array $data + * @param string $content + * @param string $secondContent + * @return array + */ + public static function getProduceLinkingBloc(array $data, string $content, string $secondContent): array + { + $data = self::emptyWysiwygBloc($data, 'second', $content); + $data = self::emptyButtonBooleanBloc($data, 'On vous écoute'); + $data = self::emptyWysiwygBloc($data, 'third', $secondContent); + $data = self::emptyButtonBooleanBloc($data, 'On se Dévoile'); + return $data; + } + + /** + * Empty bloc for picture. + * + * @param array $data + * @param string $img + * @param string $imgAlt + * @param string $imgTitle + * @param integer $width + * @param integer $height + * @param boolean $required + * @return array + */ + private static function emptyPictureBloc( + array $data, + string $img = '', + string $imgAlt = '', + string $imgTitle = '', + int $width = 100, + int $height = 100, + bool $required = false, + ) { + $data["bloc_image"] = [ + 'label' => "Image", + 'dimensions' => ['width' => $width, 'height' => $height], + 'inputType' => InputType::image->value, + 'alt' => $imgAlt, + 'title' => $imgTitle, + 'value' => $img, + 'validate' => $required ? 'required' : 'nullable', + 'required' => $required + ]; + + return $data; + } + + /** + * Empty bloc for link associated to the picture. + * + * @param array $data + * @param string $url + * @param boolean $required + * @return array + */ + private static function emptyPictureLinkBloc( + array $data, + string $url = '', + bool $required = false, + ) { + $data["bloc_image_link"] = [ + 'label' => "URL à ouvrir", + 'inputType' => InputType::url->value, + 'value' => $url, + 'validate' => $required ? 'required' : 'nullable', + 'required' => $required + ]; + + $data["bloc_image_link_new_tab"] = [ + 'label' => "Ouvrir dans un nouvel onglet", + 'inputType' => InputType::boolean->value, + ]; + + return $data; + } + + /** + * Empty bloc for key numbers. + * + * @param array $data + * @param string $name + * @param integer $value + * @param boolean $required + * + * @return array + */ + private static function emptyKeyNumberBloc( + array $data, + string $name, + int $value = 0, + bool $required = false, + ) { + $snakeCaseName = Str::of($name)->snake()->ascii()->remove(['\'', '-']); + + $data['bloc_key_' . $snakeCaseName] = [ + 'label' => "Chiffre clé {$name}", + 'inputType' => InputType::number->value, + 'value' => $value, + 'validate' => $required ? 'required' : 'nullable', + 'required' => $required + ]; + + return $data; + } + + /** + * Empty bloc for the button boolean. + * + * @param array $data + * @param string $name + * @return array + */ + private static function emptyButtonBooleanBloc( + array $data, + string $name + ) { + $snakeCaseName = Str::of($name)->snake()->ascii()->remove(['\'', '-']); + + $data["bloc_button_{$snakeCaseName}"] = [ + 'label' => "Afficher le bouton {$name} ?", + 'inputType' => InputType::boolean->value, + ]; + + return $data; + } + + /** + * Empty bloc for the h3 title. + * + * @param array $data + * @param string $name + * @param string $value + * @param boolean $required + * @return array + */ + private static function emptyH3Bloc( + array $data, + string $name, + string $value = '', + bool $required = false + ) { + $snakeCaseName = Str::of($name)->snake()->ascii()->remove(['\'', '-']); + + $data["bloc_h3_{$snakeCaseName}"] = [ + 'label' => "Titre de la section {$name}", + 'inputType' => InputType::string->value, + 'validate' => $required ? 'required' : 'nullable', + 'value' => $value, + 'required' => $required + ]; + + return $data; + } + + /** + * Empty bloc for the WYSIWYG content. + * + * @param array $data + * @param string $name + * @param string $value + * @param boolean $advanced + * @param boolean $required + * @return array + */ + private static function emptyWysiwygBloc( + array $data, + string $name, + string $value = '', + bool $advanced = false, + bool $required = false + ) { + $snakeCaseName = Str::of($name)->snake()->ascii()->remove(['\'', '-'])->remove(['\'', '-']); + + $data["bloc_{$snakeCaseName}_content"] = [ + 'label' => "Titre de la section {$name}", + 'inputType' => InputType::text->value, + 'validate' => $required ? 'required' : 'nullable', + 'value' => $value, + 'advanced' => $advanced, + 'required' => $required + ]; + + return $data; + } +} diff --git a/app/Models/Site.php b/app/Models/Site.php new file mode 100644 index 0000000..7f61bd1 --- /dev/null +++ b/app/Models/Site.php @@ -0,0 +1,244 @@ + + */ + protected $fillable = [ + 'seo_title', + 'seo_description', + 'name', + 'slug', + 'description', + 'description_2', + 'employees', + 'pictos', + 'address', + 'phone_number', + 'access_line', + 'director_name', + 'director_speach', + 'employee_name', + 'employee_function', + 'employee_speach', + 'highlights', + 'latitude', + 'longitude', + 'logo', + 'logo_alt', + 'logo_title', + 'picture_1', + 'picture_1_alt', + 'picture_1_title', + 'picture_2', + 'picture_2_alt', + 'picture_2_title', + 'picture_3', + 'picture_3_alt', + 'picture_3_title', + 'map_picture', + 'map_picture_alt', + 'map_picture_title', + 'order', + ]; + + /** + * Perform any actions required after the model boots. + * + * @return void + */ + protected static function booted(): void + { + static::creating(function (self $model) { + self::setOrder($model); + self::manageFields($model); + }); + static::updating(function (self $model) { + self::manageFields($model); + }); + static::updated(function (self $model) { + FileStorageHelper::removeOldFile($model, 'picture'); + }); + + static::deleted(function (self $model) { + FileStorageHelper::removeFile($model, 'picture'); + }); + } + + // * METHODS + + /** + * Manage model fields. + * + * @param self $model + * @return void + */ + private static function manageFields(self $model): void + { + // * ASSERTIONS + self::assertFieldIsUnique('name', $model->name); + self::assertFieldIsUnique('slug', Str::slug($model->name)); + + // * TRANSFORMATIONS + self::setSlug($model, $model->name); + $model->logo = FileStorageHelper::storeFile($model, $model->logo, true); + $model->picture_1 = FileStorageHelper::storeFile($model, $model->picture_1, true); + $model->picture_2 = FileStorageHelper::storeFile($model, $model->picture_2, true); + $model->picture_3 = FileStorageHelper::storeFile($model, $model->picture_3, true); + $model->map_picture = FileStorageHelper::storeFile($model, $model->map_picture, true); + } + + /** + * Set the slug. + * + * @param self $model + * @param string $original + * + * @return void + */ + private static function setSlug(self $model, string $original): void + { + $model->slug = Str::slug($original); + } + + /** + * Set order after the last element of the list. + * + * @param self $model + * @return void + */ + private static function setOrder(self $model): void + { + $model->order = \intval(self::query()->max('order')) + 1; + } + + /** + * Asserts using validation that the field is unique. + * + * @param string $nameField + * @param string $valueField + * @param integer|null $id + * @return void + */ + private static function assertFieldIsUnique(string $nameField, string $valueField, ?int $id = null): void + { + $table = (new self())->getTable(); + ToolboxHelper::assertFieldIsUnique($table, $nameField, $valueField, $id); + } + + /** + * Adjusts model status using current status and publish dates + * + * @param self $model + * @return void + */ + private static function makeStatusSense(self $model): void + { + /** @var \Carbon\Carbon|null */ + $publish_at = $model->publish_at; + /** @var \Carbon\Carbon|null */ + $unpublish_at = $model->unpublish_at; + $wantedStatus = $model->published; + if ($publish_at or $unpublish_at) { + $model->published = $model->planificated_status; + } + if ($wantedStatus !== $model->published) { + $previousMessage = session()->get('bo.info', ''); + session()->flash('bo.info', \trans( + 'La publication est modifiée en concordance avec les dates enregistrées. + Pour modifier l\'état de publication, veuillez modifier ou enlever les dates correspondantes.' + ) . " \n{$previousMessage}"); + } + } + + /** + * Getter the current status following planification dates planificated_status + * + * @return boolean + */ + public function getPlanificatedStatusAttribute(): bool + { + /** @var \Carbon\Carbon|null */ + $publish_at = $this->publish_at; + /** @var \Carbon\Carbon|null */ + $unpublish_at = $this->unpublish_at; + if ($publish_at and $unpublish_at) { + return $unpublish_at->greaterThanOrEqualTo(now()) and $publish_at->lessThan(now()); + } + if ($publish_at) { + return $publish_at->lessThan(now()); + } + if ($unpublish_at) { + return $unpublish_at->greaterThanOrEqualTo(now()); + } + return false; + } + + // * RELATIONS + + /** + * The logos that belong to the site. + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + */ + public function logos(): \Illuminate\Database\Eloquent\Relations\BelongsToMany + { + return $this->belongsToMany(Logo::class); + } +} diff --git a/app/Models/Slide.php b/app/Models/Slide.php new file mode 100644 index 0000000..defbd93 --- /dev/null +++ b/app/Models/Slide.php @@ -0,0 +1,91 @@ + + */ + protected $fillable = [ + 'title', + 'text', + 'button_status', + 'button_label', + 'button_url', + 'button_new_tab', + 'picture', + 'picture_alt', + 'picture_title', + ]; + + /** + * The attributes that should be cast. + * + * @var array + */ + protected $casts = [ + 'slider' => \App\Enums\Slides\SliderTypeEnum::class, + 'button_status' => 'boolean', + 'button_new_tab' => 'boolean', + ]; + + /** + * Perform any actions required after the model boots. + * + * @return void + */ + protected static function booted(): void + { + static::creating(function (self $model) { + self::manageFields($model); + }); + static::updating(function (self $model) { + self::manageFields($model); + }); + static::updated(function (self $model) { + FileStorageHelper::removeOldFile($model, 'picture'); + }); + + static::deleted(function (self $model) { + FileStorageHelper::removeFile($model, 'picture'); + }); + } + + // * METHODS + + /** + * Manage model fields. + * + * @param self $model + * @return void + */ + private static function manageFields(self $model): void + { + $model->picture = FileStorageHelper::storeFile($model, $model->picture, true); + } +} diff --git a/app/Models/StaticPage.php b/app/Models/StaticPage.php index 68d6376..97aab70 100644 --- a/app/Models/StaticPage.php +++ b/app/Models/StaticPage.php @@ -16,8 +16,8 @@ use Illuminate\Support\Str; * @property string $title Title for the page. * @property string $slug Slug of the title for the page. * @property string $content WYSIWYG text content using ckeditor. - * @property-read \Illuminate\Support\Carbon $created_at Created date. - * @property-read \Illuminate\Support\Carbon $updated_at Updated date. + * @property-read \Carbon\Carbon $created_at Created date. + * @property-read \Carbon\Carbon $updated_at Updated date. */ class StaticPage extends Model { @@ -52,12 +52,8 @@ class StaticPage extends Model */ protected static function booted(): void { - static::creating(function (self $model) { - // * ASSERTIONS - static::assertTitleIsUnique($model->title); - - // * CHANGES - $model->slug = Str::slug($model->title); + static::creating(function () { + throw new \RuntimeException("Creating a new page is not authorized"); }); static::updating(function (self $model) { // * ASSERTIONS @@ -66,6 +62,9 @@ class StaticPage extends Model // * CHANGES $model->slug = Str::slug($model->title); }); + static::deleting(function () { + throw new \RuntimeException('Deleting a page is not authorized'); + }); } // * METHODS diff --git a/app/Models/Strip.php b/app/Models/Strip.php new file mode 100644 index 0000000..50e3841 --- /dev/null +++ b/app/Models/Strip.php @@ -0,0 +1,138 @@ + + */ + protected $fillable = [ + 'picto', + 'text', + 'published', + 'publish_at', + 'unpublish_at', + 'news_id', + ]; + + /** + * The attributes that should be cast. + * + * @var array + */ + protected $casts = [ + 'picto' => \App\Enums\Strips\PictoEnum::class, + 'published' => 'bool', + 'publish_at' => 'datetime', + 'unpublish_at' => 'datetime', + ]; + + /** + * Perform any actions required after the model boots. + * + * @return void + */ + protected static function booted(): void + { + static::creating(function (self $model) { + self::manageFields($model); + }); + static::updating(function (self $model) { + self::manageFields($model); + }); + } + + // * METHODS + + /** + * Manage model fields. + * + * @param self $model + * @return void + */ + private static function manageFields(self $model): void + { + self::makeStatusSense($model); + } + + /** + * Adjusts model status using current status and publish dates + * + * @param self $model + * @return void + */ + private static function makeStatusSense(self $model): void + { + /** @var \Carbon\Carbon|null */ + $publish_at = $model->publish_at; + /** @var \Carbon\Carbon|null */ + $unpublish_at = $model->unpublish_at; + $wantedStatus = $model->published; + if ($publish_at or $unpublish_at) { + $model->published = $model->planificated_status; + } + if ($wantedStatus !== $model->published) { + $previousMessage = session()->get('bo.info', ''); + session()->flash('bo.info', \trans( + 'La publication est modifiée en concordance avec les dates enregistrées. + Pour modifier l\'état de publication, veuillez modifier ou enlever les dates correspondantes.' + ) . " \n{$previousMessage}"); + } + } + + /** + * Getter the current status following planification dates planificated_status + * + * @return boolean + */ + public function getPlanificatedStatusAttribute(): bool + { + /** @var \Carbon\Carbon|null */ + $publish_at = $this->publish_at; + /** @var \Carbon\Carbon|null */ + $unpublish_at = $this->unpublish_at; + if ($publish_at and $unpublish_at) { + return $unpublish_at->greaterThanOrEqualTo(now()) and $publish_at->lessThan(now()); + } + if ($publish_at) { + return $publish_at->lessThan(now()); + } + if ($unpublish_at) { + return $unpublish_at->greaterThanOrEqualTo(now()); + } + return false; + } + + // * RELATIONS + + /** + * Get the news that owns the strip. + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ + public function news(): \Illuminate\Database\Eloquent\Relations\BelongsTo + { + return $this->belongsTo(News::class); + } +} diff --git a/app/Models/Testimonial.php b/app/Models/Testimonial.php new file mode 100644 index 0000000..64a1c5c --- /dev/null +++ b/app/Models/Testimonial.php @@ -0,0 +1,82 @@ + + */ + protected $fillable = [ + 'name', + 'job', + 'content', + 'type', + 'picture', + 'picture_alt', + 'picture_title', + ]; + + /** + * The attributes that should be cast. + * + * @var array + */ + protected $casts = [ + 'type' => \App\Enums\Testimonials\TypeEnum::class, + ]; + + /** + * Perform any actions required after the model boots. + * + * @return void + */ + protected static function booted(): void + { + static::creating(function (self $model) { + self::manageFields($model); + }); + static::updating(function (self $model) { + self::manageFields($model); + }); + static::updated(function (self $model) { + FileStorageHelper::removeOldFile($model, 'picture'); + }); + + static::deleted(function (self $model) { + FileStorageHelper::removeFile($model, 'picture'); + }); + } + + // * METHODS + + /** + * Manage model fields. + * + * @param self $model + * @return void + */ + private static function manageFields(self $model): void + { + $model->picture = FileStorageHelper::storeFile($model, $model->picture, true); + } +} diff --git a/app/Models/User.php b/app/Models/User.php index 91ae6f9..53b50e9 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -17,8 +17,8 @@ use Illuminate\Support\Facades\Hash; * @property \App\Enums\Users\RoleEnum $role Rôle. * @property \Illuminate\Support\Carbon $published État de publication. * @property \Illuminate\Support\Carbon $published_at Date de mise à jour de l'état de publication. - * @property-read \Illuminate\Support\Carbon $created_at Created date. - * @property-read \Illuminate\Support\Carbon $updated_at Updated date. + * @property-read \Carbon\Carbon $created_at Created date. + * @property-read \Carbon\Carbon $updated_at Updated date. * * @property-read \App\Models\ActivityLog $activityLogs Activities logs One-to-many relationship. */ diff --git a/database/factories/HistoricalMilestoneFactory.php b/database/factories/HistoricalMilestoneFactory.php new file mode 100644 index 0000000..1890260 --- /dev/null +++ b/database/factories/HistoricalMilestoneFactory.php @@ -0,0 +1,28 @@ + + */ + public function definition() + { + return [ + 'title' => fake()->text(35), + 'text' => fake()->sentence(), + 'picture_alt' => fake()->sentence(), + 'picture_title' => fake()->sentence(), + 'button_status' => fake()->boolean(75), + 'button_label' => fake()->text(35), + 'button_url' => 'https://www.youtube.com/watch?v=6B4O-_1CQoI', + 'button_new_tab' => fake()->boolean(75), + 'year' => fake()->year(), + ]; + } +} diff --git a/database/factories/JobVideoFactory.php b/database/factories/JobVideoFactory.php new file mode 100644 index 0000000..d80ba01 --- /dev/null +++ b/database/factories/JobVideoFactory.php @@ -0,0 +1,22 @@ + + */ + public function definition() + { + return [ + 'title' => fake()->text(35), + 'place' => fake()->city(), + 'video_id' => '6B4O-_1CQoI', + ]; + } +} diff --git a/database/factories/LogoFactory.php b/database/factories/LogoFactory.php new file mode 100644 index 0000000..d999e03 --- /dev/null +++ b/database/factories/LogoFactory.php @@ -0,0 +1,21 @@ + + */ + public function definition() + { + return [ + 'picture_alt' => fake()->sentence(), + 'picture_title' => fake()->sentence(), + ]; + } +} diff --git a/database/factories/NewsFactory.php b/database/factories/NewsFactory.php new file mode 100644 index 0000000..5684fda --- /dev/null +++ b/database/factories/NewsFactory.php @@ -0,0 +1,40 @@ + + */ + public function definition() + { + $title = fake()->sentence(); + $publish_at = now()->subDays(rand(1, 30)); + $unpublish_at = $publish_at->copy()->addDays(rand(1, 30)); + $published = now() > $publish_at && now() < $unpublish_at ? true : false; + + return [ + 'seo_title' => fake()->text(70), + 'seo_description' => fake()->text(160), + 'title' => $title, + 'slug' => Str::slug($title), + 'introduction' => \clean(\fake()->randomHtml(6, 7)), + 'content' => \clean(\fake()->randomHtml(6, 7)), + // phpcs:ignore Generic.Files.LineLength.TooLong + 'linkedin_url' => 'https://fr.linkedin.com/posts/s-n-v_collaborateurs-sant%C3%A9-s%C3%A9curit%C3%A9-activity-7129898234935697408-DV-J', + 'thumbnail_alt' => fake()->sentence(), + 'thumbnail_title' => fake()->sentence(), + 'picture_alt' => fake()->sentence(), + 'picture_title' => fake()->sentence(), + 'published' => $published, + 'publish_at' => $publish_at, + 'unpublish_at' => $unpublish_at, + ]; + } +} diff --git a/database/factories/SectionFactory.php b/database/factories/SectionFactory.php new file mode 100644 index 0000000..51ab365 --- /dev/null +++ b/database/factories/SectionFactory.php @@ -0,0 +1,21 @@ + + */ + public function definition() + { + return [ + 'h2_title' => fake()->text(70), + 'text' => \clean(\fake()->randomHtml(2, 1)), + ]; + } +} diff --git a/database/factories/SiteFactory.php b/database/factories/SiteFactory.php new file mode 100644 index 0000000..1773ed9 --- /dev/null +++ b/database/factories/SiteFactory.php @@ -0,0 +1,56 @@ + + */ + public function definition() + { + $name = fake()->text(100); + $pictos = \collect(SpeciesEnum::cases()); + return [ + 'seo_title' => fake()->text(70), + 'seo_description' => fake()->text(160), + 'name' => $name, + 'slug' => Str::slug($name), + 'description' => fake()->text(35), + 'description_2' => fake()->text(35), + 'employees' => fake()->randomNumber(), + 'pictos' => \json_encode($pictos->random(rand(0, $pictos->count()))), + 'address' => fake()->address(), + 'phone_number' => fake()->phoneNumber(), + 'access_line' => \json_encode([ + fake()->sentence(), + fake()->sentence(), + fake()->sentence(), + ]), + 'director_name' => fake()->name(), + 'director_speach' => \clean(\fake()->randomHtml(6, 7)), + 'employee_name' => fake()->name(), + 'employee_function' => fake()->jobTitle(), + 'employee_speach' => \clean(\fake()->randomHtml(6, 7)), + 'highlights' => \clean(\fake()->randomHtml(6, 7)), + 'latitude' => fake()->latitude(), + 'longitude' => fake()->longitude(), + 'logo_alt' => fake()->sentence(), + 'logo_title' => fake()->sentence(), + 'picture_1_alt' => fake()->sentence(), + 'picture_1_title' => fake()->sentence(), + 'picture_2_alt' => fake()->sentence(), + 'picture_2_title' => fake()->sentence(), + 'picture_3_alt' => fake()->sentence(), + 'picture_3_title' => fake()->sentence(), + 'map_picture_alt' => fake()->sentence(), + 'map_picture_title' => fake()->sentence(), + ]; + } +} diff --git a/database/factories/SlideFactory.php b/database/factories/SlideFactory.php new file mode 100644 index 0000000..e0d92de --- /dev/null +++ b/database/factories/SlideFactory.php @@ -0,0 +1,27 @@ + + */ + public function definition() + { + return [ + 'title' => fake()->text(35), + 'content' => fake()->text(35), + 'picture_alt' => fake()->sentence(), + 'picture_title' => fake()->sentence(), + 'button_status' => fake()->boolean(75), + 'button_label' => fake()->text(35), + 'button_url' => 'https://www.youtube.com/watch?v=6B4O-_1CQoI', + 'button_new_tab' => fake()->boolean(75), + ]; + } +} diff --git a/database/factories/StripFactory.php b/database/factories/StripFactory.php new file mode 100644 index 0000000..21051f2 --- /dev/null +++ b/database/factories/StripFactory.php @@ -0,0 +1,31 @@ + + */ + public function definition() + { + $publish_at = now()->subDays(rand(1, 30)); + $unpublish_at = $publish_at->copy()->addDays(rand(1, 30)); + $published = now() > $publish_at && now() < $unpublish_at ? true : false; + + return [ + 'picto' => \collect(PictoEnum::cases())->random(), + 'text' => fake()->text(), + 'published' => $published, + 'publish_at' => $publish_at, + 'unpublish_at' => $unpublish_at, + 'news_id' => News::inRandomOrder()->first() + ]; + } +} diff --git a/database/factories/TestimonialFactory.php b/database/factories/TestimonialFactory.php new file mode 100644 index 0000000..8d1789f --- /dev/null +++ b/database/factories/TestimonialFactory.php @@ -0,0 +1,26 @@ + + */ + public function definition() + { + $name = fake()->text(100); + + return [ + 'name' => fake()->name(), + 'job' => fake()->jobTitle(), + 'content' => \clean(\fake()->randomHtml(6, 7)), + 'picture_alt' => fake()->sentence(), + 'picture_title' => fake()->sentence(), + ]; + } +} diff --git a/database/factories/assets/historical_milestones/default-picture-100x100.png b/database/factories/assets/historical_milestones/default-picture-100x100.png new file mode 100644 index 0000000000000000000000000000000000000000..877d378bfb62328bf666a4247f6d6ffb4cdca064 GIT binary patch literal 581 zcmeAS@N?(olHy`uVBq!ia0vp^DIm~-?n81EKJ|fuK4Svq)o}8hZnx5{I@8mRm-0sz4JoRrCDdwc=sIp z_l@?%Mjqy>_CfKks>dQQ~sWzq%*6x7YPl&YOOG@x>JyT}P89 zKHvHN_j~;{*ZKb*u=ZfB)r6 zCbB$i``$|@Uozo6{NZft*G)e{4!*9?6czAx&|%!jazuz$jQtEsU-&P~{q1)Pm^>If MUHx3vIVCg!0EJ%rs{jB1 literal 0 HcmV?d00001 diff --git a/database/factories/assets/logos/default-picture-100x100.png b/database/factories/assets/logos/default-picture-100x100.png new file mode 100644 index 0000000000000000000000000000000000000000..877d378bfb62328bf666a4247f6d6ffb4cdca064 GIT binary patch literal 581 zcmeAS@N?(olHy`uVBq!ia0vp^DIm~-?n81EKJ|fuK4Svq)o}8hZnx5{I@8mRm-0sz4JoRrCDdwc=sIp z_l@?%Mjqy>_CfKks>dQQ~sWzq%*6x7YPl&YOOG@x>JyT}P89 zKHvHN_j~;{*ZKb*u=ZfB)r6 zCbB$i``$|@Uozo6{NZft*G)e{4!*9?6czAx&|%!jazuz$jQtEsU-&P~{q1)Pm^>If MUHx3vIVCg!0EJ%rs{jB1 literal 0 HcmV?d00001 diff --git a/database/factories/assets/news/default-picture-100x100.png b/database/factories/assets/news/default-picture-100x100.png new file mode 100644 index 0000000000000000000000000000000000000000..877d378bfb62328bf666a4247f6d6ffb4cdca064 GIT binary patch literal 581 zcmeAS@N?(olHy`uVBq!ia0vp^DIm~-?n81EKJ|fuK4Svq)o}8hZnx5{I@8mRm-0sz4JoRrCDdwc=sIp z_l@?%Mjqy>_CfKks>dQQ~sWzq%*6x7YPl&YOOG@x>JyT}P89 zKHvHN_j~;{*ZKb*u=ZfB)r6 zCbB$i``$|@Uozo6{NZft*G)e{4!*9?6czAx&|%!jazuz$jQtEsU-&P~{q1)Pm^>If MUHx3vIVCg!0EJ%rs{jB1 literal 0 HcmV?d00001 diff --git a/database/factories/assets/sections/default-picture-100x100.png b/database/factories/assets/sections/default-picture-100x100.png new file mode 100644 index 0000000000000000000000000000000000000000..877d378bfb62328bf666a4247f6d6ffb4cdca064 GIT binary patch literal 581 zcmeAS@N?(olHy`uVBq!ia0vp^DIm~-?n81EKJ|fuK4Svq)o}8hZnx5{I@8mRm-0sz4JoRrCDdwc=sIp z_l@?%Mjqy>_CfKks>dQQ~sWzq%*6x7YPl&YOOG@x>JyT}P89 zKHvHN_j~;{*ZKb*u=ZfB)r6 zCbB$i``$|@Uozo6{NZft*G)e{4!*9?6czAx&|%!jazuz$jQtEsU-&P~{q1)Pm^>If MUHx3vIVCg!0EJ%rs{jB1 literal 0 HcmV?d00001 diff --git a/database/factories/assets/sites/default-picture-100x100.png b/database/factories/assets/sites/default-picture-100x100.png new file mode 100644 index 0000000000000000000000000000000000000000..877d378bfb62328bf666a4247f6d6ffb4cdca064 GIT binary patch literal 581 zcmeAS@N?(olHy`uVBq!ia0vp^DIm~-?n81EKJ|fuK4Svq)o}8hZnx5{I@8mRm-0sz4JoRrCDdwc=sIp z_l@?%Mjqy>_CfKks>dQQ~sWzq%*6x7YPl&YOOG@x>JyT}P89 zKHvHN_j~;{*ZKb*u=ZfB)r6 zCbB$i``$|@Uozo6{NZft*G)e{4!*9?6czAx&|%!jazuz$jQtEsU-&P~{q1)Pm^>If MUHx3vIVCg!0EJ%rs{jB1 literal 0 HcmV?d00001 diff --git a/database/factories/assets/slides/default-picture-100x100.png b/database/factories/assets/slides/default-picture-100x100.png new file mode 100644 index 0000000000000000000000000000000000000000..877d378bfb62328bf666a4247f6d6ffb4cdca064 GIT binary patch literal 581 zcmeAS@N?(olHy`uVBq!ia0vp^DIm~-?n81EKJ|fuK4Svq)o}8hZnx5{I@8mRm-0sz4JoRrCDdwc=sIp z_l@?%Mjqy>_CfKks>dQQ~sWzq%*6x7YPl&YOOG@x>JyT}P89 zKHvHN_j~;{*ZKb*u=ZfB)r6 zCbB$i``$|@Uozo6{NZft*G)e{4!*9?6czAx&|%!jazuz$jQtEsU-&P~{q1)Pm^>If MUHx3vIVCg!0EJ%rs{jB1 literal 0 HcmV?d00001 diff --git a/database/factories/assets/testimonials/default-picture-100x100.png b/database/factories/assets/testimonials/default-picture-100x100.png new file mode 100644 index 0000000000000000000000000000000000000000..877d378bfb62328bf666a4247f6d6ffb4cdca064 GIT binary patch literal 581 zcmeAS@N?(olHy`uVBq!ia0vp^DIm~-?n81EKJ|fuK4Svq)o}8hZnx5{I@8mRm-0sz4JoRrCDdwc=sIp z_l@?%Mjqy>_CfKks>dQQ~sWzq%*6x7YPl&YOOG@x>JyT}P89 zKHvHN_j~;{*ZKb*u=ZfB)r6 zCbB$i``$|@Uozo6{NZft*G)e{4!*9?6czAx&|%!jazuz$jQtEsU-&P~{q1)Pm^>If MUHx3vIVCg!0EJ%rs{jB1 literal 0 HcmV?d00001 diff --git a/database/migrations/2023_11_14_142558_create_news_table.php b/database/migrations/2023_11_14_142558_create_news_table.php index 8bc9091..c4a526a 100644 --- a/database/migrations/2023_11_14_142558_create_news_table.php +++ b/database/migrations/2023_11_14_142558_create_news_table.php @@ -28,8 +28,9 @@ return new class extends Migration $table->string('picture')->comment('Path de l\'image de l\'actualité'); $table->string('picture_alt')->comment('Attribut alt de l\'image de l\'actualité'); $table->string('picture_title')->comment('Attribut title de l\'image de l\'actualité'); + $table->integer('order')->comment('Numéro permettant d\'ordonner les actualités'); $table->boolean('published')->comment('L\'actualité est-elle visible ?'); - $table->timestamp('publish_at')->useCurrent()->comment('Date de publication de l\'actualité'); + $table->timestamp('publish_at')->nullable()->comment('Date de publication de l\'actualité'); $table->timestamp('unpublish_at')->nullable()->comment('Date de dépublication de l\'actualité'); $table->timestamps(); }); diff --git a/database/migrations/2023_11_14_142558_create_sections_table.php b/database/migrations/2023_11_14_142558_create_sections_table.php index fc20a63..0df2202 100644 --- a/database/migrations/2023_11_14_142558_create_sections_table.php +++ b/database/migrations/2023_11_14_142558_create_sections_table.php @@ -26,7 +26,7 @@ return new class extends Migration On s\'engage-Engagements, On bouge ensemble-Vie de l\'entreprise et engagements, large gamme locale, retrouvez en GMS, RHD, Export, Qualité - Avancé obligatoire pour On étudie'); - $table->json('additionnal_content')->comment('Minicrud content'); + $table->json('data')->comment('Minicrud content'); $table->unsignedBigInteger('page_id')->comment('Page associée'); $table->timestamps(); }); diff --git a/database/migrations/2023_11_14_142558_create_sites_table.php b/database/migrations/2023_11_14_142558_create_sites_table.php index c84b6c9..8d883d9 100644 --- a/database/migrations/2023_11_14_142558_create_sites_table.php +++ b/database/migrations/2023_11_14_142558_create_sites_table.php @@ -22,7 +22,7 @@ return new class extends Migration $table->string('description')->comment('Premier niveau de description du site'); $table->string('description_2')->nullable()->comment('Deuxième niveau de description du site'); $table->unsignedInteger('employees')->comment('Nombre d\'employés du site'); - $table->json('pictos')->comment('Tableau de value d\'enum, entre 0 et n. SpeciesEnum'); + $table->json('pictos')->comment('JSON de value d\'enum, entre 0 et n. SpeciesEnum'); $table->string('address')->comment('Adresse du site'); $table->string('phone_number')->comment('Numéro de téléphone du site'); $table->json('access_line')->comment('JSON avec 3 lignes (string) de texte décrivant l\'accès au site'); diff --git a/database/migrations/2023_11_14_142558_create_slides_table.php b/database/migrations/2023_11_14_142558_create_slides_table.php index 9905e57..068b850 100644 --- a/database/migrations/2023_11_14_142558_create_slides_table.php +++ b/database/migrations/2023_11_14_142558_create_slides_table.php @@ -15,11 +15,11 @@ return new class extends Migration { Schema::create('slides', function (Blueprint $table) { $table->id(); - $table->unsignedTinyInteger('slider')->unique()->comment('SliderTypeEnum'); + $table->unsignedTinyInteger('slider')->comment('SliderTypeEnum'); $table->string('title')->nullable() ->comment('Titre de la slide. Optionnel si le slider est home, sinon obligatoire'); $table->string('content')->nullable()->comment('Descriptif de la slide. Texte multi-line'); - $table->string('video_id', 11)->nullable() + $table->string('video_id', 11) ->comment('Id de la video Youtube. Optionnel si le slider est home, sinon le champ reste vide.'); $table->boolean('button_status')->comment('Le bouton est-il visible ?'); $table->string('button_label')->nullable() diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index bf08078..0bd3f89 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -15,6 +15,15 @@ class DatabaseSeeder extends Seeder { $this->call([ UserSeeder::class, + HistoricalMilestoneSeeder::class, + JobVideoSeeder::class, + LogoSeeder::class, + NewsSeeder::class, + SectionSeeder::class, + SiteSeeder::class, + SlideSeeder::class, + StripSeeder::class, + TestimonialSeeder::class ]); } } diff --git a/database/seeders/HistoricalMilestoneSeeder.php b/database/seeders/HistoricalMilestoneSeeder.php new file mode 100644 index 0000000..a0dd414 --- /dev/null +++ b/database/seeders/HistoricalMilestoneSeeder.php @@ -0,0 +1,29 @@ +make()->each(function (HistoricalMilestone $historicalMilestone) { + $historicalMilestone->picture = FileStorageHelper::storeFile( + new HistoricalMilestone(), + new \SplFileInfo(\resource_path( + '../database/factories/assets/historical_milestones/default-picture-100x100.png' + )) + ); + $historicalMilestone->save(); + }); + } +} diff --git a/database/seeders/JobVideoSeeder.php b/database/seeders/JobVideoSeeder.php new file mode 100644 index 0000000..946f005 --- /dev/null +++ b/database/seeders/JobVideoSeeder.php @@ -0,0 +1,19 @@ +create(); + } +} diff --git a/database/seeders/LogoSeeder.php b/database/seeders/LogoSeeder.php new file mode 100644 index 0000000..b605d70 --- /dev/null +++ b/database/seeders/LogoSeeder.php @@ -0,0 +1,29 @@ +make()->each(function (Logo $logo) { + $logo->picture = FileStorageHelper::storeFile( + new Logo(), + new \SplFileInfo(\resource_path( + '../database/factories/assets/logos/default-picture-100x100.png' + )) + ); + $logo->save(); + }); + } +} diff --git a/database/seeders/NewsSeeder.php b/database/seeders/NewsSeeder.php new file mode 100644 index 0000000..4fa039a --- /dev/null +++ b/database/seeders/NewsSeeder.php @@ -0,0 +1,35 @@ +make()->each(function (News $news) { + $news->thumbnail = FileStorageHelper::storeFile( + new News(), + new \SplFileInfo(\resource_path( + '../database/factories/assets/news/default-picture-100x100.png' + )) + ); + $news->picture = FileStorageHelper::storeFile( + new News(), + new \SplFileInfo(\resource_path( + '../database/factories/assets/news/default-picture-100x100.png' + )) + ); + $news->save(); + }); + } +} diff --git a/database/seeders/SectionSeeder.php b/database/seeders/SectionSeeder.php new file mode 100644 index 0000000..eb4d7c3 --- /dev/null +++ b/database/seeders/SectionSeeder.php @@ -0,0 +1,298 @@ +make()->each(function (Section $section) use ($sectionEnum) { + $section->section = $sectionEnum->value; + $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/default-picture-100x100.png' + )) + ), + fake()->sentence(), + fake()->sentence(), + 100, + 100, + 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/default-picture-100x100.png' + )) + ), + fake()->sentence(), + fake()->sentence(), + 100, + 100, + 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( + [], + 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 - Living section. + * + * @param \App\Models\Section $section + * @return array + */ + private function getCommitLivingData(\App\Models\Section $section) + { + return $section->getCommitLivingBloc( + [], + \clean(\fake()->randomHtml()) + ); + } + + /** + * 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()) + ); + } + + /** + * 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 Move - Commitments section. + * + * @param \App\Models\Section $section + * @return array + */ + private function getMoveCommitmentsData(\App\Models\Section $section) + { + return $section->getMoveCommitmentsBloc([]); + } + + /** + * Get MiniCrud datas for Produce - Linking section. + * + * @param \App\Models\Section $section + * @return array + */ + private function getProduceLinkingData(\App\Models\Section $section) + { + return $section->getProduceLinkingBloc( + [], + \clean(\fake()->randomHtml()), + \clean(\fake()->randomHtml()) + ); + } +} diff --git a/database/seeders/SiteSeeder.php b/database/seeders/SiteSeeder.php new file mode 100644 index 0000000..598b7c3 --- /dev/null +++ b/database/seeders/SiteSeeder.php @@ -0,0 +1,53 @@ +make()->each(function (Site $site) { + $site->logo = FileStorageHelper::storeFile( + new Site(), + new \SplFileInfo(\resource_path( + '../database/factories/assets/sites/default-picture-100x100.png' + )) + ); + $site->picture_1 = FileStorageHelper::storeFile( + new Site(), + new \SplFileInfo(\resource_path( + '../database/factories/assets/sites/default-picture-100x100.png' + )) + ); + $site->picture_2 = FileStorageHelper::storeFile( + new Site(), + new \SplFileInfo(\resource_path( + '../database/factories/assets/sites/default-picture-100x100.png' + )) + ); + $site->picture_3 = FileStorageHelper::storeFile( + new Site(), + new \SplFileInfo(\resource_path( + '../database/factories/assets/sites/default-picture-100x100.png' + )) + ); + $site->map_picture = FileStorageHelper::storeFile( + new Site(), + new \SplFileInfo(\resource_path( + '../database/factories/assets/sites/default-picture-100x100.png' + )) + ); + $site->save(); + }); + } +} diff --git a/database/seeders/SlideSeeder.php b/database/seeders/SlideSeeder.php new file mode 100644 index 0000000..2e82518 --- /dev/null +++ b/database/seeders/SlideSeeder.php @@ -0,0 +1,34 @@ +make()->each(function (Slide $slide) use ($slider) { + $slide->slider = $slider->value; + $slide->video_id = $slider === SliderTypeEnum::home ? '6B4O-_1CQoI' : ''; + $slide->picture = FileStorageHelper::storeFile( + new Slide(), + new \SplFileInfo(\resource_path( + '../database/factories/assets/slides/default-picture-100x100.png' + )) + ); + $slide->save(); + }); + } + } +} diff --git a/database/seeders/StaticPageSeeder.php b/database/seeders/StaticPageSeeder.php index 57d2f39..6339ea8 100644 --- a/database/seeders/StaticPageSeeder.php +++ b/database/seeders/StaticPageSeeder.php @@ -5,6 +5,7 @@ namespace Database\Seeders; use App\Enums\StaticPageType; use App\Models\StaticPage; use Illuminate\Database\Seeder; +use Illuminate\Support\Str; class StaticPageSeeder extends Seeder { @@ -15,41 +16,140 @@ class StaticPageSeeder extends Seeder */ public function run() { - StaticPage::query()->updateOrCreate( - [ - 'type' => StaticPageType::contact, - ], - [ - 'seo_title' => 'Seo title pour la page contactez nous', - 'seo_description' => 'Seo description pour la page contactez nous', - 'title' => 'Contactez-nous', - 'type' => StaticPageType::contact, - 'content' => \clean(\fake()->randomHtml(6, 7)), - ] - ); - StaticPage::query()->updateOrCreate( - [ - 'type' => StaticPageType::legals, - ], - [ - 'seo_title' => 'Seo title pour la page mentions légales', - 'seo_description' => 'Seo description pour la page mentions légales', - 'title' => 'Mentions légales', - 'type' => StaticPageType::legals, - 'content' => \clean(\fake()->randomHtml(6, 7)), - ] - ); - StaticPage::query()->updateOrCreate( - [ - 'type' => StaticPageType::confidentiality, - ], - [ - 'seo_title' => 'Seo title pour la page charte de confidentialitée', - 'seo_description' => 'Seo description pour la page charte de confidentialitée', - 'title' => 'Charte de confidentialitée', - 'type' => StaticPageType::confidentiality, - 'content' => \clean(\fake()->randomHtml(6, 7)), - ] - ); + try { + StaticPage::unsetEventDispatcher(); + StaticPage::query()->updateOrCreate( + [ + 'type' => StaticPageType::contact, + ], + [ + 'seo_title' => 'Seo title pour la page contactez nous', + 'seo_description' => 'Seo description pour la page contactez nous', + 'title' => 'Contactez-nous', + 'slug' => Str::slug('Contactez-nous'), + 'type' => StaticPageType::contact, + 'content' => \clean(\fake()->randomHtml(6, 7)), + ] + ); + StaticPage::query()->updateOrCreate( + [ + 'type' => StaticPageType::legals, + ], + [ + 'seo_title' => 'Seo title pour la page mentions légales', + 'seo_description' => 'Seo description pour la page mentions légales', + 'title' => 'Mentions légales', + 'slug' => Str::slug('Mentions légales'), + 'type' => StaticPageType::legals, + 'content' => \clean(\fake()->randomHtml(6, 7)), + ] + ); + StaticPage::query()->updateOrCreate( + [ + 'type' => StaticPageType::confidentiality, + ], + [ + 'seo_title' => 'Seo title pour la page charte de confidentialité', + 'seo_description' => 'Seo description pour la page charte de confidentialité', + 'title' => 'Charte de confidentialité', + 'slug' => Str::slug('Charte de confidentialité'), + 'type' => StaticPageType::confidentiality, + 'content' => \clean(\fake()->randomHtml(6, 7)), + ] + ); + StaticPage::query()->updateOrCreate( + [ + 'type' => StaticPageType::home, + ], + [ + 'seo_title' => 'Seo title pour la page Accueil', + 'seo_description' => 'Seo description pour la page Accueil', + 'title' => 'Accueil', + 'slug' => Str::slug('Accueil'), + 'type' => StaticPageType::home, + 'content' => '', + ] + ); + StaticPage::query()->updateOrCreate( + [ + 'type' => StaticPageType::unveil, + ], + [ + 'seo_title' => 'Seo title pour la page On se Dévoile', + 'seo_description' => 'Seo description pour la page On se Dévoile', + 'title' => 'On se Dévoile', + 'slug' => Str::slug('On se Dévoile'), + 'type' => StaticPageType::unveil, + 'content' => '', + ] + ); + StaticPage::query()->updateOrCreate( + [ + 'type' => StaticPageType::we_hire, + ], + [ + 'seo_title' => 'Seo title pour la page On Embauche', + 'seo_description' => 'Seo description pour la page On Embauche', + 'title' => 'On Embauche', + 'slug' => Str::slug('On Embauche'), + 'type' => StaticPageType::we_hire, + 'content' => '', + ] + ); + StaticPage::query()->updateOrCreate( + [ + 'type' => StaticPageType::we_commit, + ], + [ + 'seo_title' => 'Seo title pour la page On s\'Engage', + 'seo_description' => 'Seo description pour la page On s\'Engage', + 'title' => 'On s\'Engage', + 'slug' => Str::slug('On s\'Engage'), + 'type' => StaticPageType::we_commit, + 'content' => '', + ] + ); + StaticPage::query()->updateOrCreate( + [ + 'type' => StaticPageType::we_move, + ], + [ + 'seo_title' => 'Seo title pour la page On Bouge Ensemble', + 'seo_description' => 'Seo description pour la page On Bouge Ensemble', + 'title' => 'On Bouge Ensemble', + 'slug' => Str::slug('On Bouge Ensemble'), + 'type' => StaticPageType::we_move, + 'content' => '', + ] + ); + StaticPage::query()->updateOrCreate( + [ + 'type' => StaticPageType::we_produce, + ], + [ + 'seo_title' => 'Seo title pour la page On Produit', + 'seo_description' => 'Seo description pour la page On Produit', + 'title' => 'On Produit', + 'slug' => Str::slug('On Produit'), + 'type' => StaticPageType::we_produce, + 'content' => '', + ] + ); + StaticPage::query()->updateOrCreate( + [ + 'type' => StaticPageType::we_listen, + ], + [ + 'seo_title' => 'Seo title pour la page On Vous Ecoute', + 'seo_description' => 'Seo description pour la page On Vous Ecoute', + 'title' => 'On Vous Ecoute', + 'slug' => Str::slug('On Vous Ecoute'), + 'type' => StaticPageType::we_listen, + 'content' => '', + ] + ); + } finally { + StaticPage::setEventDispatcher(new \Illuminate\Events\Dispatcher()); + } //end try } } diff --git a/database/seeders/StripSeeder.php b/database/seeders/StripSeeder.php new file mode 100644 index 0000000..66265d6 --- /dev/null +++ b/database/seeders/StripSeeder.php @@ -0,0 +1,21 @@ +create(); + } +} diff --git a/database/seeders/TestimonialSeeder.php b/database/seeders/TestimonialSeeder.php new file mode 100644 index 0000000..68caec8 --- /dev/null +++ b/database/seeders/TestimonialSeeder.php @@ -0,0 +1,33 @@ +make()->each(function (Testimonial $testimonial) use ($type) { + $testimonial->type = $type->value; + $testimonial->picture = FileStorageHelper::storeFile( + new Testimonial(), + new \SplFileInfo(\resource_path( + '../database/factories/assets/testimonials/default-picture-100x100.png' + )) + ); + $testimonial->save(); + }); + } + } +}