Added seeders and factories
75
app/Enums/Sections/PageSectionEnum.php
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
|
||||
namespace App\Enums\Sections;
|
||||
|
||||
use App\Traits\Enums\BaseEnum;
|
||||
|
||||
enum PageSectionEnum: int
|
||||
{
|
||||
use BaseEnum;
|
||||
|
||||
case home_missions = 1;
|
||||
case home_ambition = 2;
|
||||
case home_team = 3;
|
||||
case home_life = 4;
|
||||
case unveil_pole = 5;
|
||||
case unveil_local = 6;
|
||||
case unveil_sites = 7;
|
||||
case unveil_history = 8;
|
||||
case unveil_commitments = 9;
|
||||
case hire_life = 10;
|
||||
case hire_formation = 11;
|
||||
case hire_grow = 12;
|
||||
case hire_parity = 13;
|
||||
case hire_find = 14;
|
||||
case commit_ambition = 15;
|
||||
case commit_breeding = 16;
|
||||
case commit_living = 17;
|
||||
case commit_respect_earth = 18;
|
||||
case commit_feed = 19;
|
||||
case commit_commitments = 20;
|
||||
case move_life = 21;
|
||||
case move_commitments = 22;
|
||||
case produce_local = 23;
|
||||
case produce_gms = 24;
|
||||
case produce_rhd = 25;
|
||||
case produce_export = 26;
|
||||
case produce_quality = 27;
|
||||
case produce_linking = 28;
|
||||
case listening_study = 29;
|
||||
|
||||
/**
|
||||
* Optionnal labels definition.
|
||||
*/
|
||||
private const LABELS = [
|
||||
self::home_missions->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',
|
||||
];
|
||||
}
|
||||
31
app/Enums/Sites/SpeciesEnum.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace App\Enums\Sites;
|
||||
|
||||
use App\Traits\Enums\BaseEnum;
|
||||
|
||||
enum SpeciesEnum: int
|
||||
{
|
||||
use BaseEnum;
|
||||
|
||||
case chicken = 1;
|
||||
case turkey = 2;
|
||||
case hen = 3;
|
||||
case duck = 4;
|
||||
case rabbit = 5;
|
||||
case guinea_fowl = 6;
|
||||
case rooster = 7;
|
||||
|
||||
/**
|
||||
* Optionnal labels definition.
|
||||
*/
|
||||
private const LABELS = [
|
||||
self::chicken->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',
|
||||
];
|
||||
}
|
||||
23
app/Enums/Slides/SliderTypeEnum.php
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace App\Enums\Slides;
|
||||
|
||||
use App\Traits\Enums\BaseEnum;
|
||||
|
||||
enum SliderTypeEnum: int
|
||||
{
|
||||
use BaseEnum;
|
||||
|
||||
case home = 1;
|
||||
case better_life = 2;
|
||||
case respect_earth = 3;
|
||||
|
||||
/**
|
||||
* Optionnal labels definition.
|
||||
*/
|
||||
private const LABELS = [
|
||||
self::home->name => 'Accueil',
|
||||
self::better_life->name => 'Mieux vivre',
|
||||
self::respect_earth->name => 'Respecter la terre',
|
||||
];
|
||||
}
|
||||
|
|
@ -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',
|
||||
];
|
||||
}
|
||||
|
|
|
|||
29
app/Enums/Strips/PictoEnum.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace App\Enums\Strips;
|
||||
|
||||
use App\Traits\Enums\BaseEnum;
|
||||
|
||||
enum PictoEnum: int
|
||||
{
|
||||
use BaseEnum;
|
||||
|
||||
case danger = 1;
|
||||
case respect_earth = 2;
|
||||
case breeding = 3;
|
||||
case feed = 4;
|
||||
case better_life = 5;
|
||||
case none = 6;
|
||||
|
||||
/**
|
||||
* Optionnal labels definition.
|
||||
*/
|
||||
private const LABELS = [
|
||||
self::danger->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',
|
||||
];
|
||||
}
|
||||
29
app/Enums/Testimonials/TypeEnum.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace App\Enums\Testimonials;
|
||||
|
||||
use App\Traits\Enums\BaseEnum;
|
||||
|
||||
enum TypeEnum: int
|
||||
{
|
||||
use BaseEnum;
|
||||
|
||||
case breeding = 1;
|
||||
case better_life = 2;
|
||||
case respect_earth = 3;
|
||||
case feed = 4;
|
||||
case volena = 5;
|
||||
case hire = 6;
|
||||
|
||||
/**
|
||||
* Optionnal labels definition.
|
||||
*/
|
||||
private const LABELS = [
|
||||
self::breeding->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',
|
||||
];
|
||||
}
|
||||
|
|
@ -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'))
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
|||
89
app/Models/HistoricalMilestone.php
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Lib\Helpers\FileStorageHelper;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* @property string $title Title.
|
||||
* @property string $text Description.
|
||||
* @property string $picture Path of the image.
|
||||
* @property string $picture_alt Alt attribute of the image.
|
||||
* @property string $picture_title Title attribute of the image.
|
||||
* @property boolean $button_status Is the button visible ?.
|
||||
* @property string $button_label Button label, max 35 characters. Required if the button is visible.
|
||||
* @property string $button_url Button URL. equired if the button is visible.
|
||||
* @property boolean $button_new_tab Does the link need to be opened in a new tab ?
|
||||
* @property integer $year Year of the historical milestone.
|
||||
* @property-read \Carbon\Carbon $created_at Created date.
|
||||
* @property-read \Carbon\Carbon $updated_at Updated date.
|
||||
*/
|
||||
class HistoricalMilestone extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
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<string, string>
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
29
app/Models/JobVideo.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* @property string $title Title.
|
||||
* @property string $place Place of the video.
|
||||
* @property string $video_id Id of the Youtube video.
|
||||
* @property-read \Carbon\Carbon $created_at Created date.
|
||||
* @property-read \Carbon\Carbon $updated_at Updated date.
|
||||
*/
|
||||
class JobVideo extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'place',
|
||||
'video_id',
|
||||
];
|
||||
}
|
||||
80
app/Models/Logo.php
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Lib\Helpers\FileStorageHelper;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* @property string $picture Path of the image.
|
||||
* @property string $picture_alt Alt attribute of the image.
|
||||
* @property string $picture_title Title attribute of the image.
|
||||
* @property-read \Carbon\Carbon $created_at Created date.
|
||||
* @property-read \Carbon\Carbon $updated_at Updated date.
|
||||
*
|
||||
* @property-read \App\Models\Site $sites Sites Many-to-many relationship.
|
||||
|
||||
*/
|
||||
class Logo extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
203
app/Models/News.php
Normal file
|
|
@ -0,0 +1,203 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Lib\Helpers\FileStorageHelper;
|
||||
use App\Lib\Helpers\ToolboxHelper;
|
||||
use App\Traits\Models\ActivityLog;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @property string $seo_title SEO title.
|
||||
* @property string $seo_description SEO description.
|
||||
* @property string $title Title.
|
||||
* @property string $slug Slug of the title.
|
||||
* @property string $introduction WYSIWYG - Introduction.
|
||||
* @property string|null $content WYSIWYG - Content.
|
||||
* @property string|null $linkedin_url Url of the linkedin related post.
|
||||
* @property string $thumbnail Path of the thumbnail.
|
||||
* @property string $thumbnail_alt Thumbnail alt attribute.
|
||||
* @property string $thumbnail_title Thumbnail title attribute.
|
||||
* @property string $picture Path of the picture.
|
||||
* @property string $picture_alt Picture alt attribute..
|
||||
* @property string $picture_title Picture title attribute.
|
||||
* @property integer $order Order.
|
||||
* @property boolean $published Publication status.
|
||||
* @property \Carbon\Carbon|null $publish_at Publication date.
|
||||
* @property \Carbon\Carbon|null $unpublish_at Unpublication status update date.
|
||||
* @property-read \Carbon\Carbon $created_at Created date.
|
||||
* @property-read \Carbon\Carbon $updated_at Updated date.
|
||||
*/
|
||||
class News extends Model
|
||||
{
|
||||
use ActivityLog;
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
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<string, string>
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
525
app/Models/Section.php
Normal file
|
|
@ -0,0 +1,525 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\InputType;
|
||||
use App\Enums\Sections\PageSectionEnum;
|
||||
use App\Lib\Helpers\FileStorageHelper;
|
||||
use App\Lib\Helpers\ToolboxHelper;
|
||||
use App\Traits\Models\MiniCrudModel;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @property App\Enums\Sections\PageSectionEnum $section Slider that contains the slide.
|
||||
* @property string $h2_title Title.
|
||||
* @property string $text WYSIWYG - Content.
|
||||
* @property string $data Minicrud content.
|
||||
* @property-read \Carbon\Carbon $created_at Created date.
|
||||
* @property-read \Carbon\Carbon $updated_at Updated date.
|
||||
*/
|
||||
class Section extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use MiniCrudModel;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'section',
|
||||
'h2_title',
|
||||
'text',
|
||||
'data',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
244
app/Models/Site.php
Normal file
|
|
@ -0,0 +1,244 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Lib\Helpers\FileStorageHelper;
|
||||
use App\Lib\Helpers\ToolboxHelper;
|
||||
use App\Traits\Models\ActivityLog;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @property string $seo_title SEO title.
|
||||
* @property string $seo_description SEO description.
|
||||
* @property string $name Name.
|
||||
* @property string $slug Slug of the name.
|
||||
* @property string $description First level of description.
|
||||
* @property string $description_2 Second level of description.
|
||||
* @property integer $employees Employees count.
|
||||
* @property string $pictos JSON - SpeciesEnum Values. Between 0 and n.
|
||||
* @property string $address Address of the site.
|
||||
* @property string $phone_number Phone number of the site.
|
||||
* @property string $access_line JSON - How to go to the site. 3 entries.
|
||||
* @property string $director_name Name of the director.
|
||||
* @property string $director_speach WYSIWYG - Director speach.
|
||||
* @property string $employee_name Name of the employee.
|
||||
* @property string $employee_function Function of the employee.
|
||||
* @property string $employee_speach WYSIWYG - Employee speach.
|
||||
* @property string $highlights WYSIWYG - Highlights part content.
|
||||
* @property double $latitude Latitude in degrees.
|
||||
* @property double $longitude Longitude in degrees.
|
||||
* @property string $logo Path of the logo.
|
||||
* @property string $logo_alt Logo alt attribute.
|
||||
* @property string $logo_title Logo title attribute.
|
||||
* @property string $picture_1 Path of the picture 1.
|
||||
* @property string $picture_1_alt Picture 1 alt attribute.
|
||||
* @property string $picture_1_title Picture 1 title attribute.
|
||||
* @property string $picture_2 Path of the picture 2.
|
||||
* @property string $picture_2_alt Picture 2 alt attribute.
|
||||
* @property string $picture_2_title Picture 2 title attribute.
|
||||
* @property string $picture_3 Path of the picture 3.
|
||||
* @property string $picture_3_alt Picture 3 alt attribute.
|
||||
* @property string $picture_3_title Picture 3 title attribute.
|
||||
* @property string $map_picture Path of the map picture.
|
||||
* @property string $map_picture_alt Map picture alt attribute.
|
||||
* @property string $map_picture_title Map picture title attribute.
|
||||
* @property integer $order Order.
|
||||
* @property-read \Carbon\Carbon $created_at Created date.
|
||||
* @property-read \Carbon\Carbon $updated_at Updated date.
|
||||
*
|
||||
* @property-read \App\Models\Logo $logos Logos Many-to-many relationship.
|
||||
*/
|
||||
class Site extends Model
|
||||
{
|
||||
use ActivityLog;
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
91
app/Models/Slide.php
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Lib\Helpers\FileStorageHelper;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* @property App\Enums\Slides\SliderTypeEnum $slider Slider that contains the slide.
|
||||
* @property string $title Title.
|
||||
* @property string $content WYSIWYG - Content.
|
||||
* @property string $video_id Id of the Youtube video.
|
||||
* @property boolean $button_status Is the button visible ?.
|
||||
* @property string $button_label Button label, max 35 chars.
|
||||
* Required if button_status == true.
|
||||
* @property string $button_url Button URL. equired if the button is visible.
|
||||
* @property boolean $button_new_tab Does the link need to be opened in a new tab ?
|
||||
* @property string $picture Path of the image.
|
||||
* @property string $picture_alt Alt attribute of the image.
|
||||
* @property string $picture_title Title attribute of the image.
|
||||
* @property-read \Carbon\Carbon $created_at Created date.
|
||||
* @property-read \Carbon\Carbon $updated_at Updated date.
|
||||
*/
|
||||
class Slide extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
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<string, string>
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
|
|||
138
app/Models/Strip.php
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\Models\ActivityLog;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* @property App\Enums\Strips\PictoEnum $picto Picto.
|
||||
* @property string $text WYSIWYG restrained (blod and underline only). Text.
|
||||
* @property boolean $published Publication status.
|
||||
* @property \Carbon\Carbon|null $publish_at Publication date.
|
||||
* @property \Carbon\Carbon|null $unpublish_at Unpublication status update date.
|
||||
* @property-read \Carbon\Carbon $created_at Created date.
|
||||
* @property-read \Carbon\Carbon $updated_at Updated date.
|
||||
*
|
||||
* @property-read \App\Models\News $news News Belongs to relationship.
|
||||
*/
|
||||
class Strip extends Model
|
||||
{
|
||||
use ActivityLog;
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'picto',
|
||||
'text',
|
||||
'published',
|
||||
'publish_at',
|
||||
'unpublish_at',
|
||||
'news_id',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
82
app/Models/Testimonial.php
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Lib\Helpers\FileStorageHelper;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* @property string $name Name of the person.
|
||||
* @property string $job Function of the person.
|
||||
* @property string $content WYSIWYG - Content.
|
||||
* @property App\Enums\Testimonial\TypeEnum $type Type of the testimonial.
|
||||
* @property string $picture Path of the image.
|
||||
* @property string $picture_alt Alt attribute of the image.
|
||||
* @property string $picture_title Title attribute of the image.
|
||||
* @property-read \Carbon\Carbon $created_at Created date.
|
||||
* @property-read \Carbon\Carbon $updated_at Updated date.
|
||||
*/
|
||||
class Testimonial extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'job',
|
||||
'content',
|
||||
'type',
|
||||
'picture',
|
||||
'picture_alt',
|
||||
'picture_title',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
|||
28
database/factories/HistoricalMilestoneFactory.php
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class HistoricalMilestoneFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
22
database/factories/JobVideoFactory.php
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class JobVideoFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'title' => fake()->text(35),
|
||||
'place' => fake()->city(),
|
||||
'video_id' => '6B4O-_1CQoI',
|
||||
];
|
||||
}
|
||||
}
|
||||
21
database/factories/LogoFactory.php
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class LogoFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'picture_alt' => fake()->sentence(),
|
||||
'picture_title' => fake()->sentence(),
|
||||
];
|
||||
}
|
||||
}
|
||||
40
database/factories/NewsFactory.php
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class NewsFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
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,
|
||||
];
|
||||
}
|
||||
}
|
||||
21
database/factories/SectionFactory.php
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class SectionFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'h2_title' => fake()->text(70),
|
||||
'text' => \clean(\fake()->randomHtml(2, 1)),
|
||||
];
|
||||
}
|
||||
}
|
||||
56
database/factories/SiteFactory.php
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\Sites\SpeciesEnum;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class SiteFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
27
database/factories/SlideFactory.php
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class SlideFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
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),
|
||||
];
|
||||
}
|
||||
}
|
||||
31
database/factories/StripFactory.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\Strips\PictoEnum;
|
||||
use App\Models\News;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class StripFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
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()
|
||||
];
|
||||
}
|
||||
}
|
||||
26
database/factories/TestimonialFactory.php
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class TestimonialFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 581 B |
BIN
database/factories/assets/logos/default-picture-100x100.png
Normal file
|
After Width: | Height: | Size: 581 B |
BIN
database/factories/assets/news/default-picture-100x100.png
Normal file
|
After Width: | Height: | Size: 581 B |
BIN
database/factories/assets/sections/default-picture-100x100.png
Normal file
|
After Width: | Height: | Size: 581 B |
BIN
database/factories/assets/sites/default-picture-100x100.png
Normal file
|
After Width: | Height: | Size: 581 B |
BIN
database/factories/assets/slides/default-picture-100x100.png
Normal file
|
After Width: | Height: | Size: 581 B |
|
After Width: | Height: | Size: 581 B |
|
|
@ -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();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
29
database/seeders/HistoricalMilestoneSeeder.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Lib\Helpers\FileStorageHelper;
|
||||
use App\Models\HistoricalMilestone;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class HistoricalMilestoneSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
FileStorageHelper::removeModelFiles(new HistoricalMilestone());
|
||||
HistoricalMilestone::factory(10)->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();
|
||||
});
|
||||
}
|
||||
}
|
||||
19
database/seeders/JobVideoSeeder.php
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\JobVideo;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class JobVideoSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
JobVideo::factory(8)->create();
|
||||
}
|
||||
}
|
||||
29
database/seeders/LogoSeeder.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Lib\Helpers\FileStorageHelper;
|
||||
use App\Models\Logo;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class LogoSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
FileStorageHelper::removeModelFiles(new Logo());
|
||||
Logo::factory(10)->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();
|
||||
});
|
||||
}
|
||||
}
|
||||
35
database/seeders/NewsSeeder.php
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Lib\Helpers\FileStorageHelper;
|
||||
use App\Models\News;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class NewsSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
FileStorageHelper::removeModelFiles(new News());
|
||||
News::factory(10)->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();
|
||||
});
|
||||
}
|
||||
}
|
||||
298
database/seeders/SectionSeeder.php
Normal file
|
|
@ -0,0 +1,298 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
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;
|
||||
|
||||
class SectionSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
FileStorageHelper::removeModelFiles(new Section());
|
||||
|
||||
foreach (PageSectionEnum::cases() as $sectionEnum) {
|
||||
Section::factory(1)->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())
|
||||
);
|
||||
}
|
||||
}
|
||||
53
database/seeders/SiteSeeder.php
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Lib\Helpers\FileStorageHelper;
|
||||
use App\Models\Site;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class SiteSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
FileStorageHelper::removeModelFiles(new Site());
|
||||
Site::factory(10)->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();
|
||||
});
|
||||
}
|
||||
}
|
||||
34
database/seeders/SlideSeeder.php
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Enums\Slides\SliderTypeEnum;
|
||||
use App\Lib\Helpers\FileStorageHelper;
|
||||
use App\Models\Slide;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class SlideSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
FileStorageHelper::removeModelFiles(new Slide());
|
||||
foreach (SliderTypeEnum::cases() as $slider) {
|
||||
Slide::factory(3)->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();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
21
database/seeders/StripSeeder.php
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Lib\Helpers\FileStorageHelper;
|
||||
use App\Models\Strip;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class StripSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
FileStorageHelper::removeModelFiles(new Strip());
|
||||
Strip::factory(10)->create();
|
||||
}
|
||||
}
|
||||
33
database/seeders/TestimonialSeeder.php
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Enums\Testimonials\TypeEnum;
|
||||
use App\Lib\Helpers\FileStorageHelper;
|
||||
use App\Models\Testimonial;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class TestimonialSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
FileStorageHelper::removeModelFiles(new Testimonial());
|
||||
foreach (TypeEnum::cases() as $type) {
|
||||
Testimonial::factory(3)->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();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||