Close #5 seeders factories
33
app/Console/Commands/UpdateNewsStatus.php
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Jobs\NewsStatusUpdate;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class TestMail extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'uwil:updatestatus:news';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Update news status according to the publish and unpublish dates';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
\dispatch(new NewsStatusUpdate());
|
||||
}
|
||||
}
|
||||
33
app/Console/Commands/UpdateSeasonalSectionsStatus.php
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Jobs\SeasonalSectionStatusUpdate;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class TestMail extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'uwil:updatestatus:seasonalsections';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Update seasonal sections status according to the publish and unpublish dates';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
\dispatch(new SeasonalSectionStatusUpdate());
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace App\Console;
|
||||
|
||||
use App\Jobs\NewsStatusUpdate;
|
||||
use App\Jobs\SeasonalSectionStatusUpdate;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
|
|
@ -15,6 +17,8 @@ class Kernel extends ConsoleKernel
|
|||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
$schedule->job(NewsStatusUpdate::class)->everyMinute();
|
||||
$schedule->job(SeasonalSectionStatusUpdate::class)->everyMinute();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
27
app/Enums/News/CategoryEnum.php
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace App\Enums\News;
|
||||
|
||||
use App\Traits\Enums\BaseEnum;
|
||||
|
||||
enum CategoryEnum: int
|
||||
{
|
||||
use BaseEnum;
|
||||
|
||||
case enterprise = 1;
|
||||
case convictions = 2;
|
||||
case recipes = 3;
|
||||
case jobs = 4;
|
||||
case communication = 5;
|
||||
|
||||
/**
|
||||
* Optionnal labels definition.
|
||||
*/
|
||||
private const LABELS = [
|
||||
self::enterprise->name => 'La vie d\'Entreprise',
|
||||
self::convictions->name => 'Nos convictions',
|
||||
self::recipes->name => 'Nos recettes',
|
||||
self::jobs->name => 'Nos métiers',
|
||||
self::communication->name => 'Communication',
|
||||
];
|
||||
}
|
||||
27
app/Enums/Products/CookingModeEnum.php
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace App\Enums\Products;
|
||||
|
||||
use App\Traits\Enums\BaseEnum;
|
||||
|
||||
enum CookingModeEnum: int
|
||||
{
|
||||
use BaseEnum;
|
||||
|
||||
case microwave = 1;
|
||||
case furnace = 2;
|
||||
case waterbath = 3;
|
||||
case pan = 4;
|
||||
case fresh = 5;
|
||||
|
||||
/**
|
||||
* Optionnal labels definition.
|
||||
*/
|
||||
private const LABELS = [
|
||||
self::microwave->name => 'Micro-ondes',
|
||||
self::furnace->name => 'Four traditionnel',
|
||||
self::waterbath->name => 'Bain-marie',
|
||||
self::pan->name => 'Poêle',
|
||||
self::fresh->name => 'Se consomme frais',
|
||||
];
|
||||
}
|
||||
23
app/Enums/SeasonalSections/BackgroundEnum.php
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace App\Enums\SeasonalSections;
|
||||
|
||||
use App\Traits\Enums\BaseEnum;
|
||||
|
||||
enum BackgroundEnum: int
|
||||
{
|
||||
use BaseEnum;
|
||||
|
||||
case candlemas = 1;
|
||||
case chinesenewyear = 2;
|
||||
case endofyear = 3;
|
||||
|
||||
/**
|
||||
* Optionnal labels definition.
|
||||
*/
|
||||
private const LABELS = [
|
||||
self::candlemas->name => 'Chandeleur',
|
||||
self::chinesenewyear->name => 'Nouvel an chinois',
|
||||
self::endofyear->name => 'Fin d\'année',
|
||||
];
|
||||
}
|
||||
37
app/Enums/StaticPageType.php
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use App\Traits\Enums\BaseEnum;
|
||||
|
||||
enum StaticPageType: int
|
||||
{
|
||||
use BaseEnum;
|
||||
|
||||
case contact = 1;
|
||||
case legals = 2;
|
||||
case confidentiality = 3;
|
||||
case home = 4;
|
||||
case conviction = 5;
|
||||
case explorer = 6;
|
||||
case joinus = 7;
|
||||
case ranges = 8;
|
||||
case aboutus = 9;
|
||||
case news = 10;
|
||||
|
||||
/**
|
||||
* Optionnal labels definition.
|
||||
*/
|
||||
private const LABELS = [
|
||||
self::contact->name => 'Contact',
|
||||
self::legals->name => 'Mentions légales',
|
||||
self::confidentiality->name => 'Confidentialité',
|
||||
self::home->name => 'Accueil',
|
||||
self::conviction->name => 'Nos Convictions',
|
||||
self::explorer->name => 'Explorate & Gastronome',
|
||||
self::joinus->name => 'Rejoignez-nous',
|
||||
self::ranges->name => 'Nos Gammes de Produits',
|
||||
self::aboutus->name => 'Nous Connaître',
|
||||
self::news->name => 'Actualités',
|
||||
];
|
||||
}
|
||||
46
app/Jobs/NewsStatusUpdate.php
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\News;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Update published attribute reading its
|
||||
* publish_at and unpublish_at attributes.
|
||||
*/
|
||||
class NewsStatusUpdate
|
||||
{
|
||||
/**
|
||||
* Called when the job will be executed.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
/** @var \Illuminate\Database\Eloquent\Collection<array-key, \App\Models\News> */
|
||||
$newsListToPublish = News::query()
|
||||
->where('publish_at', '<=', Carbon::now()->toDateTime())
|
||||
->whereNotNull('publish_at')
|
||||
->where('published', false)->get();
|
||||
Log::debug(__CLASS__ . " news to publish " . $newsListToPublish->count());
|
||||
foreach ($newsListToPublish as $news) {
|
||||
$news->publish_at = null;
|
||||
$news->published = true;
|
||||
$news->saveOrFail();
|
||||
}
|
||||
/** @var \Illuminate\Database\Eloquent\Collection<array-key, \App\Models\News> */
|
||||
$newsListToUnPublish = News::query()
|
||||
->where('unpublish_at', '<=', Carbon::now()->toDateTime())
|
||||
->whereNotNull('unpublish_at')
|
||||
->where('published', true)->get();
|
||||
Log::debug(__CLASS__ . " news to unpublish " . $newsListToPublish->count());
|
||||
foreach ($newsListToUnPublish as $news) {
|
||||
$news->publish_at = null;
|
||||
$news->unpublish_at = null;
|
||||
$news->published = false;
|
||||
$news->saveOrFail();
|
||||
}
|
||||
}
|
||||
}
|
||||
46
app/Jobs/SeasonalSectionStatusUpdate.php
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\SeasonalSection;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Update published attribute reading its
|
||||
* publish_at and unpublish_at attributes.
|
||||
*/
|
||||
class SeasonalSectionStatusUpdate
|
||||
{
|
||||
/**
|
||||
* Called when the job will be executed.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
/** @var \Illuminate\Database\Eloquent\Collection<array-key, \App\Models\SeasonalSections> */
|
||||
$seasonalsectionsListToPublish = SeasonalSection::query()
|
||||
->where('publish_at', '<=', Carbon::now()->toDateTime())
|
||||
->whereNotNull('publish_at')
|
||||
->where('published', false)->get();
|
||||
Log::debug(__CLASS__ . " seasonalsections to publish " . $seasonalsectionsListToPublish->count());
|
||||
foreach ($seasonalsectionsListToPublish as $seasonalsections) {
|
||||
$seasonalsections->publish_at = null;
|
||||
$seasonalsections->published = true;
|
||||
$seasonalsections->saveOrFail();
|
||||
}
|
||||
/** @var \Illuminate\Database\Eloquent\Collection<array-key, \App\Models\SeasonalSections> */
|
||||
$seasonalsectionsListToUnPublish = SeasonalSection::query()
|
||||
->where('unpublish_at', '<=', Carbon::now()->toDateTime())
|
||||
->whereNotNull('unpublish_at')
|
||||
->where('published', true)->get();
|
||||
Log::debug(__CLASS__ . " seasonalsections to unpublish " . $seasonalsectionsListToPublish->count());
|
||||
foreach ($seasonalsectionsListToUnPublish as $seasonalsections) {
|
||||
$seasonalsections->publish_at = null;
|
||||
$seasonalsections->unpublish_at = null;
|
||||
$seasonalsections->published = false;
|
||||
$seasonalsections->saveOrFail();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
108
app/Models/Commitment.php
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Lib\Helpers\FileStorageHelper;
|
||||
use App\Traits\Models\ActivityLog;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* @property string $title Titre.
|
||||
* @property string $picture Path de l'image de l'engagement (185px * 185px).
|
||||
* @property string $picture_alt Attribut alt de l'image de l'engagement.
|
||||
* @property string $picture_title Attribut title de l'image de l'engagement.
|
||||
* @property boolean $published État de publication.
|
||||
* @property integer $order Numéro permettant d'ordonner les engagements.
|
||||
* @property-read \Carbon\Carbon $created_at Created date.
|
||||
* @property-read \Carbon\Carbon $updated_at Updated date.
|
||||
*
|
||||
* @property-read \App\Models\Product $products Products Many-to-many relationship.
|
||||
* @property-read \App\Models\Page $explorerpage Pages Many-to-many relationship.
|
||||
*/
|
||||
class Commitment extends Model
|
||||
{
|
||||
use ActivityLog;
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'picture',
|
||||
'picture_alt',
|
||||
'picture_title',
|
||||
'published',
|
||||
'order',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected $casts = [
|
||||
'published' => 'bool',
|
||||
];
|
||||
|
||||
/**
|
||||
* Perform any actions required after the model boots.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::creating(function (self $model) {
|
||||
self::setOrder($model);
|
||||
$model->picture = FileStorageHelper::storeFile($model, $model->picture, true);
|
||||
});
|
||||
static::updating(function (self $model) {
|
||||
$model->picture = FileStorageHelper::storeFile($model, $model->picture, true);
|
||||
});
|
||||
static::updated(function (self $model) {
|
||||
FileStorageHelper::removeOldFile($model, 'picture');
|
||||
});
|
||||
|
||||
static::deleted(function (self $model) {
|
||||
FileStorageHelper::removeFile($model, 'picture');
|
||||
});
|
||||
}
|
||||
|
||||
// * METHODS
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
// * RELATIONS
|
||||
|
||||
/**
|
||||
* The products that belong to the commitment.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*/
|
||||
public function products(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Product::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* The page that belong to the commitment.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*/
|
||||
public function explorerpage(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Explorerpage::class);
|
||||
}
|
||||
}
|
||||
56
app/Models/Convictionpage.php
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\Models\ActivityLog;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* @property float $key_feed Chiffre clé 'bien nourrir'.
|
||||
* @property float $key_earth_1 Chiffre clé 'respecter la terre' 1.
|
||||
* @property float $key_earth_2 Chiffre clé 'respecter la terre' 2.
|
||||
* @property float $key_together_1 Chiffre clé 'vivre ensemble' 1.
|
||||
* @property float $key_together_2 Chiffre clé 'vivre ensemble' 2.
|
||||
* @property float $key_together_3 Chiffre clé 'vivre ensemble' 3.
|
||||
* @property float $key_together_4 Chiffre clé 'vivre ensemble' 4.
|
||||
* @property float $key_territory Chiffre clé 'intégrer son territoire'.
|
||||
* @property-read \Carbon\Carbon $created_at Created date.
|
||||
* @property-read \Carbon\Carbon $updated_at Updated date.
|
||||
*/
|
||||
class Convictionpage extends Model
|
||||
{
|
||||
use ActivityLog;
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'key_feed',
|
||||
'key_earth_1',
|
||||
'key_earth_2',
|
||||
'key_together_1',
|
||||
'key_together_2',
|
||||
'key_together_3',
|
||||
'key_together_4',
|
||||
'key_territory',
|
||||
];
|
||||
|
||||
/**
|
||||
* Perform any actions required after the model boots.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::creating(function () {
|
||||
throw new \RuntimeException("Creating a new page is not authorized");
|
||||
});
|
||||
static::deleting(function () {
|
||||
throw new \RuntimeException('Deleting a page is not authorized');
|
||||
});
|
||||
}
|
||||
}
|
||||
83
app/Models/Explorerpage.php
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Lib\Helpers\FileStorageHelper;
|
||||
use App\Traits\Models\ActivityLog;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* @property string $picture_1 Chiffre clé 'bien nourrir'.
|
||||
* @property string $picture_1_alt Chiffre clé 'bien nourrir'.
|
||||
* @property string $picture_1_title Chiffre clé 'bien nourrir'.
|
||||
* @property string $picture_2 Chiffre clé 'bien nourrir'.
|
||||
* @property string $picture_2_alt Chiffre clé 'bien nourrir'.
|
||||
* @property string $picture_2_title Chiffre clé 'bien nourrir'.
|
||||
* @property string $picture_3 Chiffre clé 'bien nourrir'.
|
||||
* @property string $picture_3_alt Chiffre clé 'bien nourrir'.
|
||||
* @property string $picture_3_title Chiffre clé 'bien nourrir'.
|
||||
* @property-read \Carbon\Carbon $created_at Created date.
|
||||
* @property-read \Carbon\Carbon $updated_at Updated date.
|
||||
*
|
||||
* @property-read \App\Models\Commitment $commitments Commitments Many-to-many relationship.
|
||||
*/
|
||||
class Explorerpage extends Model
|
||||
{
|
||||
use ActivityLog;
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'picture_1',
|
||||
'picture_1_alt',
|
||||
'picture_1_title',
|
||||
'picture_2',
|
||||
'picture_2_alt',
|
||||
'picture_2_title',
|
||||
'picture_3',
|
||||
'picture_3_alt',
|
||||
'picture_3_title',
|
||||
];
|
||||
|
||||
/**
|
||||
* Perform any actions required after the model boots.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::creating(function () {
|
||||
throw new \RuntimeException("Creating a new page is not authorized");
|
||||
});
|
||||
static::updating(function (self $model) {
|
||||
$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);
|
||||
});
|
||||
static::updated(function (self $model) {
|
||||
FileStorageHelper::removeOldFile($model, 'picture_1');
|
||||
FileStorageHelper::removeOldFile($model, 'picture_2');
|
||||
FileStorageHelper::removeOldFile($model, 'picture_3');
|
||||
});
|
||||
static::deleting(function () {
|
||||
throw new \RuntimeException('Deleting a page is not authorized');
|
||||
});
|
||||
}
|
||||
|
||||
// * RELATIONS
|
||||
|
||||
/**
|
||||
* The commitments that belong to the page.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*/
|
||||
public function commitments(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Commitment::class);
|
||||
}
|
||||
}
|
||||
63
app/Models/Homepage.php
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Lib\Helpers\FileStorageHelper;
|
||||
use App\Traits\Models\ActivityLog;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* @property string $title_part_1 Première partie du titre h1 de l'accueil.
|
||||
* @property string $title_part_2 Deuxième partie du titre h1 de l'accueil.
|
||||
* @property string $title_part_3 Dernière partie du titre h1 de l'accueil.
|
||||
* @property string $picture Path de l'image de la page d'accueil (640px * 390px).
|
||||
* @property string $picture_alt Attribut alt de l'image de la page d'accueil.
|
||||
* @property string $picture_title Attribut title de l'image de la page d'accueil.
|
||||
* @property string $presentation_title Titre de la partie 'présentation' de la page d'accueil.
|
||||
* @property string $presentation_content WYSIWYG - Contenu de la partie présentation de la page d'accueil.
|
||||
* @property-read \Carbon\Carbon $created_at Created date.
|
||||
* @property-read \Carbon\Carbon $updated_at Updated date.
|
||||
*/
|
||||
class Homepage extends Model
|
||||
{
|
||||
use ActivityLog;
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'title_part_1',
|
||||
'title_part_2',
|
||||
'title_part_3',
|
||||
'picture',
|
||||
'picture_alt',
|
||||
'picture_title',
|
||||
'presentation_title',
|
||||
'presentation_content',
|
||||
];
|
||||
|
||||
/**
|
||||
* Perform any actions required after the model boots.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::creating(function () {
|
||||
throw new \RuntimeException("Creating a new page is not authorized");
|
||||
});
|
||||
static::updating(function (self $model) {
|
||||
$model->picture = FileStorageHelper::storeFile($model, $model->picture, true);
|
||||
});
|
||||
static::updated(function (self $model) {
|
||||
FileStorageHelper::removeOldFile($model, 'picture');
|
||||
});
|
||||
static::deleting(function () {
|
||||
throw new \RuntimeException('Deleting a page is not authorized');
|
||||
});
|
||||
}
|
||||
}
|
||||
42
app/Models/Joinuspage.php
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\Models\ActivityLog;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* @property string $video_url Lien de la vidéo youtube à afficher.
|
||||
* @property-read \Carbon\Carbon $created_at Created date.
|
||||
* @property-read \Carbon\Carbon $updated_at Updated date.
|
||||
*/
|
||||
class Joinuspage extends Model
|
||||
{
|
||||
use ActivityLog;
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'video_url',
|
||||
];
|
||||
|
||||
/**
|
||||
* Perform any actions required after the model boots.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::creating(function () {
|
||||
throw new \RuntimeException("Creating a new page is not authorized");
|
||||
});
|
||||
static::deleting(function () {
|
||||
throw new \RuntimeException('Deleting a page is not authorized');
|
||||
});
|
||||
}
|
||||
}
|
||||
201
app/Models/News.php
Normal file
|
|
@ -0,0 +1,201 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\News\CategoryEnum;
|
||||
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 Utilisé pour la balise title de la page.
|
||||
* @property string $seo_description Utilisé pour la balise meta description de la page.
|
||||
* @property string $title Balise h1 de la page.
|
||||
* @property string $slug Slug à partir de title.
|
||||
* @property \App\Enums\News\CategoryEnum $category Catégorie de la news (\App\Enums\News\CategoryEnum).
|
||||
* @property string|null $picture_thumbnail Path de la vignette de l'actualité (265px * 354px).
|
||||
* @property string|null $picture_thumbnail_alt Attribut alt de la vignette de l'actualité.
|
||||
* @property string|null $picture_thumbnail_title Attribut title de la vignette de l'actualité.
|
||||
* @property string $picture Path de l'illustration de l'actualité (1002px*565px).
|
||||
* @property string $picture_alt Attribut alt de l'illustration de l'actualité.
|
||||
* @property string $picture_title Attribut title de l'illustration de l'actualité.
|
||||
* @property string $subtitle Sous-titre de l'actualité. Chaine vide possible.
|
||||
* @property string $content WYSIWYG - Texte de l'actualité.
|
||||
* @property boolean $published L'actualité est-elle visible ?
|
||||
* @property \Carbon\Carbon|null $publish_at Date de publication de l'actualité.
|
||||
* @property \Carbon\Carbon|null $unpublish_at Date de dépublication de l'actualité.
|
||||
* @property integer $order Numéro permettant d'ordonner les engagements.
|
||||
* @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',
|
||||
'category',
|
||||
'picture_thumbnail',
|
||||
'picture_thumbnail_alt',
|
||||
'picture_thumbnail_title',
|
||||
'picture',
|
||||
'picture_alt',
|
||||
'picture_title',
|
||||
'subtitle',
|
||||
'content',
|
||||
'published',
|
||||
'publish_at',
|
||||
'unpublish_at',
|
||||
'order',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected $casts = [
|
||||
'category' => CategoryEnum::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::assertFieldIsUnique('title', $model->title);
|
||||
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
|
||||
{
|
||||
self::setSlug($model, $model->title);
|
||||
self::makeStatusSense($model);
|
||||
$model->picture = FileStorageHelper::storeFile($model, $model->picture, true);
|
||||
$model->picture_thumbnail = FileStorageHelper::storeFile($model, $model->picture_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;
|
||||
}
|
||||
}
|
||||
192
app/Models/Product.php
Normal file
|
|
@ -0,0 +1,192 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\Products\CookingModeEnum;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @phpcs:disable Generic.Files.LineLength.TooLong
|
||||
*
|
||||
* @property string $seo_title Utilisé pour la balise title de la page.
|
||||
* @property string $seo_description Utilisé pour la balise meta description de la page.
|
||||
* @property string $title Balise h1 de la page.
|
||||
* @property string $slug Slug à partir de title.
|
||||
* @property string $subtitle Sous-titre du produit.
|
||||
* @property string $picture_thumbnail Path de la vignette du produit (332px * 252px).
|
||||
* @property string $picture_thumbnail_alt Attribut alt de la vignette du produit.
|
||||
* @property string $picture_thumbnail_title Attribut title de la vignette du produit.
|
||||
* @property string $picture_ambiance Path du visuel d'ambiance du produit (774px * 515px).
|
||||
* @property string $picture_ambiance_alt Attribut alt du visuel d'ambiance.
|
||||
* @property string $picture_ambiance_title Attribut title du visuel d'ambiance.
|
||||
* @property string $picture_packshot Path de l'image du packshot (327px * 252px).
|
||||
* @property string $picture_packshot_alt Attribut alt de l'image du packshot.
|
||||
* @property string $picture_packshot_title Attribut title de l'image du packshot.
|
||||
* @property string $description WYSIWYG - Description du produit.
|
||||
* @property \App\Enums\Products\CookingModeEnum $cooking_mode Mode de cuisson \App\Enums\Products\CookingModeEnum.
|
||||
* @property string $cooking_advice WYSIWYG - Conseil de réchauffage.
|
||||
* @property string $ingredients WYSIWYG - Ingrédients qui composent le produit.
|
||||
* @property string $nutritionnal_values JSON des valeurs nutritionnelles pour 100g.
|
||||
* @property boolean $published Le produit est-il visible ?
|
||||
* @property integer $order Numéro permettant d'ordonner les produits.
|
||||
* @property-read \Carbon\Carbon $created_at Created date.
|
||||
* @property-read \Carbon\Carbon $updated_at Updated date.
|
||||
*
|
||||
* @property-read \App\Models\Commitment $commitments Commitments Many-to-many relationship.
|
||||
* @property-read \App\Models\Range $range Range Belongs to relationship.
|
||||
* @phpcs:enable
|
||||
*/
|
||||
class Product extends Model
|
||||
{
|
||||
use ActivityLog;
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'seo_title',
|
||||
'seo_description',
|
||||
'title',
|
||||
'slug',
|
||||
'subtitle',
|
||||
'picture_thumbnail',
|
||||
'picture_thumbnail_alt',
|
||||
'picture_thumbnail_title',
|
||||
'picture_ambiance',
|
||||
'picture_ambiance_alt',
|
||||
'picture_ambiance_title',
|
||||
'picture_packshot',
|
||||
'picture_packshot_alt',
|
||||
'picture_packshot_title',
|
||||
'description',
|
||||
'cooking_mode',
|
||||
'cooking_advice',
|
||||
'ingredients',
|
||||
'nutritionnal_values',
|
||||
'published',
|
||||
'order',
|
||||
'range_id'
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected $casts = [
|
||||
'cooking_mode' => CookingModeEnum::class,
|
||||
'published' => 'bool',
|
||||
];
|
||||
|
||||
/**
|
||||
* Perform any actions required after the model boots.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::creating(function (self $model) {
|
||||
self::assertFieldIsUnique('title', $model->title);
|
||||
self::setOrder($model);
|
||||
self::manageFields($model);
|
||||
});
|
||||
static::updating(function (self $model) {
|
||||
self::manageFields($model);
|
||||
});
|
||||
static::updated(function (self $model) {
|
||||
FileStorageHelper::removeOldFile($model, 'picture_thumbnail');
|
||||
FileStorageHelper::removeOldFile($model, 'picture_ambiance');
|
||||
FileStorageHelper::removeOldFile($model, 'picture_packshot');
|
||||
});
|
||||
|
||||
static::deleted(function (self $model) {
|
||||
FileStorageHelper::removeFile($model, 'picture_thumbnail');
|
||||
FileStorageHelper::removeFile($model, 'picture_ambiance');
|
||||
FileStorageHelper::removeFile($model, 'picture_packshot');
|
||||
});
|
||||
}
|
||||
|
||||
// * METHODS
|
||||
|
||||
/**
|
||||
* Manage model fields.
|
||||
*
|
||||
* @param self $model
|
||||
* @return void
|
||||
*/
|
||||
private static function manageFields(self $model): void
|
||||
{
|
||||
self::setSlug($model, $model->title);
|
||||
$model->picture_thumbnail = FileStorageHelper::storeFile($model, $model->picture_thumbnail, true);
|
||||
$model->picture_ambiance = FileStorageHelper::storeFile($model, $model->picture_ambiance, true);
|
||||
$model->picture_packshot = FileStorageHelper::storeFile($model, $model->picture_packshot, 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);
|
||||
}
|
||||
|
||||
// * RELATIONS
|
||||
|
||||
/**
|
||||
* Get the range that owns the product.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function range(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Range::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* The commitments that belong to the product.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*/
|
||||
public function commitments(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Commitment::class);
|
||||
}
|
||||
}
|
||||
173
app/Models/Range.php
Normal file
|
|
@ -0,0 +1,173 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\Products\CookingModeEnum;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @phpcs:disable Generic.Files.LineLength.TooLong
|
||||
*
|
||||
* @property string $seo_title Utilisé pour la balise title de la page.
|
||||
* @property string $seo_description Utilisé pour la balise meta description de la page.
|
||||
* @property string $title Balise h1 de la page.
|
||||
* @property string $slug Slug à partir de title.
|
||||
* @property string $subtitle Sous-titre de la gamme.
|
||||
* @property string $tagline Titre d'accroche de la gamme.
|
||||
* @property string $description WYSIWYG - Description de la gamme.
|
||||
* @property string $picture Path de l'image de la gamme (466px * 440px).
|
||||
* @property string $picture_alt Attribut alt pour l'image picture.
|
||||
* @property string $picture_title Attribut title pour l'image picture.
|
||||
* @property string $picture_productsheet Path de l'image à afficher sur les fiches produits de cette gamme (332px * 442px).
|
||||
* @property string $picture_productsheet_alt Attribut alt de l'image à afficher sur les fiches produits.
|
||||
* @property string $picture_productsheet_title Attribut title de l'image à afficher sur les fiches produits.
|
||||
* @property string $picture_thumbnail Path de la vignette de la gamme (246px * 337px).
|
||||
* @property string $picture_thumbnail_alt Attribut alt de la vignette de la gamme.
|
||||
* @property string $picture_thumbnail_title Attribut title de la vignette de la gamme.
|
||||
* @property boolean $published Le produit est-il visible ?
|
||||
* @property integer $order Numéro permettant d'ordonner les produits.
|
||||
* @property-read \Carbon\Carbon $created_at Created date.
|
||||
* @property-read \Carbon\Carbon $updated_at Updated date.
|
||||
*
|
||||
* @property-read \App\Models\Products $products Products Has Many relationship.
|
||||
* @phpcs:enable
|
||||
*/
|
||||
class Range extends Model
|
||||
{
|
||||
use ActivityLog;
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'seo_title',
|
||||
'seo_description',
|
||||
'title',
|
||||
'slug',
|
||||
'subtitle',
|
||||
'tagline',
|
||||
'picture',
|
||||
'picture_alt',
|
||||
'picture_title',
|
||||
'picture_productsheet',
|
||||
'picture_productsheet_alt',
|
||||
'picture_productsheet_title',
|
||||
'picture_thumbnail',
|
||||
'picture_thumbnail_alt',
|
||||
'picture_thumbnail_title',
|
||||
'published',
|
||||
'order',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected $casts = [
|
||||
'cooking_mode' => CookingModeEnum::class,
|
||||
'published' => 'bool',
|
||||
];
|
||||
|
||||
/**
|
||||
* Perform any actions required after the model boots.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::creating(function (self $model) {
|
||||
self::assertFieldIsUnique('title', $model->title);
|
||||
self::setOrder($model);
|
||||
self::manageFields($model);
|
||||
});
|
||||
static::updating(function (self $model) {
|
||||
self::manageFields($model);
|
||||
});
|
||||
static::updated(function (self $model) {
|
||||
FileStorageHelper::removeOldFile($model, 'picture');
|
||||
FileStorageHelper::removeOldFile($model, 'picture_productsheet');
|
||||
FileStorageHelper::removeOldFile($model, 'picture_thumbnail');
|
||||
});
|
||||
|
||||
static::deleted(function (self $model) {
|
||||
FileStorageHelper::removeFile($model, 'picture');
|
||||
FileStorageHelper::removeFile($model, 'picture_productsheet');
|
||||
FileStorageHelper::removeFile($model, 'picture_thumbnail');
|
||||
});
|
||||
}
|
||||
|
||||
// * METHODS
|
||||
|
||||
/**
|
||||
* Manage model fields.
|
||||
*
|
||||
* @param self $model
|
||||
* @return void
|
||||
*/
|
||||
private static function manageFields(self $model): void
|
||||
{
|
||||
self::setSlug($model, $model->title);
|
||||
$model->picture = FileStorageHelper::storeFile($model, $model->picture, true);
|
||||
$model->picture_productsheet = FileStorageHelper::storeFile($model, $model->picture_productsheet, true);
|
||||
$model->picture_thumbnail = FileStorageHelper::storeFile($model, $model->picture_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);
|
||||
}
|
||||
|
||||
// * RELATIONS
|
||||
|
||||
/**
|
||||
* Get the products in the range.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function products(): \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
{
|
||||
return $this->hasMany(Product::class);
|
||||
}
|
||||
}
|
||||
146
app/Models/SeasonalSection.php
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\SeasonalSections\BackgroundEnum;
|
||||
use App\Lib\Helpers\FileStorageHelper;
|
||||
use App\Traits\Models\ActivityLog;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* @phpcs:disable Generic.Files.LineLength.TooLong
|
||||
*
|
||||
* @property string $title Titre de la section saisonnière.
|
||||
* @property string $text WYSIWYG - Texte de la section saisonnière.
|
||||
* @property string $picture Path de l'image de la section saisonnière (362px * 542px).
|
||||
* @property string $picture_alt Attribut alt de l'image.
|
||||
* @property string $picture_title Attribut title de l'image.
|
||||
* @property \App\Enums\SeasonalSections\BackgroundEnum $background Fond de la section saisonnière \App\Enums\SeasonalSections\BackgroundEnum.
|
||||
* @property boolean $published La section est-elle visible ?
|
||||
* @property \Carbon\Carbon|null $publish_at Date de publication de la section.
|
||||
* @property \Carbon\Carbon|null $unpublish_at Date de dépublication de la section.
|
||||
* @property-read \Carbon\Carbon $created_at Created date.
|
||||
* @property-read \Carbon\Carbon $updated_at Updated date.
|
||||
* @phpcs:enable
|
||||
*/
|
||||
class SeasonalSection extends Model
|
||||
{
|
||||
use ActivityLog;
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'text',
|
||||
'picture',
|
||||
'picture_alt',
|
||||
'picture_title',
|
||||
'background',
|
||||
'published',
|
||||
'publish_at',
|
||||
'unpublish_at',
|
||||
'order',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected $casts = [
|
||||
'background' => BackgroundEnum::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);
|
||||
});
|
||||
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
|
||||
{
|
||||
self::makeStatusSense($model);
|
||||
$model->picture = FileStorageHelper::storeFile($model, $model->picture, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
62
app/Models/Stamp.php
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Lib\Helpers\FileStorageHelper;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* @property string $picture Path de l'image du tampon (120px * 120px).
|
||||
* @property string $picture_alt Attribut alt de l'image du tampon.
|
||||
* @property string $picture_title Attribut title de l'image du tampon.
|
||||
* @property boolean $published Le tampon est-il visible ?
|
||||
* @property-read \Carbon\Carbon $created_at Created date.
|
||||
* @property-read \Carbon\Carbon $updated_at Updated date.
|
||||
*/
|
||||
class Stamp extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'picture',
|
||||
'picture_alt',
|
||||
'picture_title',
|
||||
'published',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected $casts = [
|
||||
'published' => 'bool',
|
||||
];
|
||||
|
||||
/**
|
||||
* Perform any actions required after the model boots.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::creating(function (self $model) {
|
||||
$model->picture = FileStorageHelper::storeFile($model, $model->picture, true);
|
||||
});
|
||||
static::updating(function (self $model) {
|
||||
$model->picture = FileStorageHelper::storeFile($model, $model->picture, true);
|
||||
});
|
||||
static::updated(function (self $model) {
|
||||
FileStorageHelper::removeOldFile($model, 'picture');
|
||||
});
|
||||
static::deleted(function (self $model) {
|
||||
FileStorageHelper::removeFile($model, 'picture');
|
||||
});
|
||||
}
|
||||
}
|
||||
86
app/Models/StaticPage.php
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\StaticPageType;
|
||||
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 \App\Enums\StaticPageType $type Page type (StaticPageEnum).
|
||||
* @property string $seo_title Seo title about 70 chars as recommended.
|
||||
* @property string $seo_description Seo description about 160 chars as recommended.
|
||||
* @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.
|
||||
*/
|
||||
class StaticPage extends Model
|
||||
{
|
||||
use ActivityLog;
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'seo_title',
|
||||
'seo_description',
|
||||
'title',
|
||||
'content',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected $casts = [
|
||||
'type' => StaticPageType::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* Perform any actions required after the model boots.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::creating(function () {
|
||||
throw new \RuntimeException("Creating a new page is not authorized");
|
||||
});
|
||||
static::updating(function (self $model) {
|
||||
// * ASSERTIONS
|
||||
static::assertTitleIsUnique($model->title, $model->id);
|
||||
|
||||
// * CHANGES
|
||||
$model->slug = Str::slug($model->title);
|
||||
});
|
||||
static::deleting(function () {
|
||||
throw new \RuntimeException('Deleting a page is not authorized');
|
||||
});
|
||||
}
|
||||
|
||||
// * METHODS
|
||||
|
||||
/**
|
||||
* Asserts using validation that the title is unique
|
||||
*
|
||||
* @param string|null $title
|
||||
* @param integer|null $id
|
||||
* @return void
|
||||
* @throws \Illuminate\Validation\ValidationException If an actu title already exists.
|
||||
*/
|
||||
private static function assertTitleIsUnique(string|null $title, ?int $id = null)
|
||||
{
|
||||
$table = (new self())->getTable();
|
||||
ToolboxHelper::assertFieldIsUnique($table, 'title', $title, $id);
|
||||
ToolboxHelper::assertFieldIsUnique($table, 'slug', Str::slug($title), $id);
|
||||
}
|
||||
}
|
||||
76
app/Models/Testimonial.php
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Lib\Helpers\FileStorageHelper;
|
||||
use App\Traits\Models\ActivityLog;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* @property string $picture Path de l'illustration du témoignage (292px * 417px).
|
||||
* @property string $picture_alt Attribut alt de l'illustration.
|
||||
* @property string $picture_title Attribut title de l'illustration.
|
||||
* @property string $description Texte du témoignage.
|
||||
* @property string $job Métier de la personne témoignant.
|
||||
* @property string $statut Statut de la personne témoignant
|
||||
* @property integer $order Numéro permettant d'ordonner les témoignages.
|
||||
* @property-read \Carbon\Carbon $created_at Created date.
|
||||
* @property-read \Carbon\Carbon $updated_at Updated date.
|
||||
*/
|
||||
class Testimonial extends Model
|
||||
{
|
||||
use ActivityLog;
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'picture',
|
||||
'picture_alt',
|
||||
'picture_title',
|
||||
'description',
|
||||
'job',
|
||||
'statut',
|
||||
'order',
|
||||
];
|
||||
|
||||
/**
|
||||
* Perform any actions required after the model boots.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::creating(function (self $model) {
|
||||
self::setOrder($model);
|
||||
$model->picture = FileStorageHelper::storeFile($model, $model->picture, true);
|
||||
});
|
||||
static::updating(function (self $model) {
|
||||
$model->picture = FileStorageHelper::storeFile($model, $model->picture, true);
|
||||
});
|
||||
static::updated(function (self $model) {
|
||||
FileStorageHelper::removeOldFile($model, 'picture');
|
||||
});
|
||||
|
||||
static::deleted(function (self $model) {
|
||||
FileStorageHelper::removeFile($model, 'picture');
|
||||
});
|
||||
}
|
||||
|
||||
// * METHODS
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
23
database/factories/CommitmentFactory.php
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class CommitmentFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'title' => fake()->sentence(),
|
||||
'picture_alt' => fake()->sentence(),
|
||||
'picture_title' => fake()->sentence(),
|
||||
'published' => fake()->boolean(75),
|
||||
];
|
||||
}
|
||||
}
|
||||
27
database/factories/ConvictionpageFactory.php
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class ConvictionpageFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'key_feed' => fake()->randomFloat(2, 0, 999999),
|
||||
'key_earth_1' => fake()->randomFloat(2, 0, 999999),
|
||||
'key_earth_2' => fake()->randomFloat(2, 0, 999999),
|
||||
'key_together_1' => fake()->randomFloat(2, 0, 999999),
|
||||
'key_together_2' => fake()->randomFloat(2, 0, 999999),
|
||||
'key_together_3' => fake()->randomFloat(2, 0, 999999),
|
||||
'key_together_4' => fake()->randomFloat(2, 0, 999999),
|
||||
'key_territory' => fake()->randomFloat(2, 0, 999999),
|
||||
];
|
||||
}
|
||||
}
|
||||
25
database/factories/ExplorerpageFactory.php
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class ExplorerpageFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
26
database/factories/HomepageFactory.php
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class HomepageFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'title_part1' => fake()->sentence(),
|
||||
'title_part2' => fake()->sentence(),
|
||||
'title_part3' => fake()->sentence(),
|
||||
'picture_alt' => fake()->sentence(),
|
||||
'picture_title' => fake()->sentence(),
|
||||
'presentation_title' => fake()->sentence(),
|
||||
'presentation_content' => \clean(\fake()->randomHtml(6, 7)),
|
||||
];
|
||||
}
|
||||
}
|
||||
20
database/factories/JoinuspageFactory.php
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class JoinuspageFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'video_url' => 'https://www.youtube.com/watch?v=6B4O-_1CQoI',
|
||||
];
|
||||
}
|
||||
}
|
||||
40
database/factories/NewsFactory.php
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\News\CategoryEnum;
|
||||
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()->word(),
|
||||
'seo_description' => fake()->text(160),
|
||||
'title' => $title,
|
||||
'slug' => Str::slug($title),
|
||||
'category' => \collect(CategoryEnum::cases())->random(),
|
||||
'picture_thumbnail_alt' => fake()->sentence(),
|
||||
'picture_thumbnail_title' => fake()->sentence(),
|
||||
'picture_alt' => fake()->sentence(),
|
||||
'picture_title' => fake()->sentence(),
|
||||
'subtitle' => fake()->sentence(),
|
||||
'content' => \clean(\fake()->randomHtml(6, 7)),
|
||||
'published' => $published,
|
||||
'publish_at' => $publish_at,
|
||||
'unpublish_at' => $unpublish_at,
|
||||
];
|
||||
}
|
||||
}
|
||||
50
database/factories/ProductFactory.php
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\Products\CookingModeEnum;
|
||||
use App\Models\Range;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class ProductFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
$title = fake()->sentence();
|
||||
|
||||
return [
|
||||
'seo_title' => fake()->word(),
|
||||
'seo_description' => fake()->text(160),
|
||||
'title' => $title,
|
||||
'slug' => Str::slug($title),
|
||||
'subtitle' => fake()->sentence(),
|
||||
'picture_thumbnail_alt' => fake()->sentence(),
|
||||
'picture_thumbnail_title' => fake()->sentence(),
|
||||
'picture_ambiance_alt' => fake()->sentence(),
|
||||
'picture_ambiance_title' => fake()->sentence(),
|
||||
'picture_packshot_alt' => fake()->sentence(),
|
||||
'picture_packshot_title' => fake()->sentence(),
|
||||
'description' => \clean(\fake()->randomHtml(6, 7)),
|
||||
'cooking_mode' => \collect(CookingModeEnum::cases())->random(),
|
||||
'cooking_advice' => \clean(\fake()->randomHtml(6, 7)),
|
||||
'ingredients' => \clean(\fake()->randomHtml(6, 7)),
|
||||
'nutritionnal_values' => json_encode([
|
||||
'Energie en Kj' => fake()->randomFloat(2),
|
||||
'Energie en kcal' => fake()->randomFloat(2),
|
||||
'Matières grasses' => fake()->randomFloat(2),
|
||||
'dont acides gras saturés' => fake()->randomFloat(2),
|
||||
'Glucides' => fake()->randomFloat(2),
|
||||
'Protéines' => fake()->randomFloat(2),
|
||||
'Sel' => fake()->randomFloat(2),
|
||||
]),
|
||||
'published' => fake()->boolean(75),
|
||||
'range_id' => Range::all()->random()->id,
|
||||
];
|
||||
}
|
||||
}
|
||||
36
database/factories/RangeFactory.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class RangeFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
$title = fake()->sentence();
|
||||
|
||||
return [
|
||||
'seo_title' => fake()->word(),
|
||||
'seo_description' => fake()->text(160),
|
||||
'title' => $title,
|
||||
'slug' => Str::slug($title),
|
||||
'subtitle' => fake()->sentence(),
|
||||
'tagline' => fake()->sentence(),
|
||||
'description' => \clean(\fake()->randomHtml(6, 7)),
|
||||
'picture_alt' => fake()->sentence(),
|
||||
'picture_title' => fake()->sentence(),
|
||||
'picture_productsheet_alt' => fake()->sentence(),
|
||||
'picture_productsheet_title' => fake()->sentence(),
|
||||
'picture_thumbnail_alt' => fake()->sentence(),
|
||||
'picture_thumbnail_title' => fake()->sentence(),
|
||||
'published' => fake()->boolean(75),
|
||||
];
|
||||
}
|
||||
}
|
||||
24
database/factories/SeasonalSectionFactory.php
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class SeasonalSectionFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'title' => fake()->sentence(),
|
||||
'text' => fake()->text(),
|
||||
'picture_alt' => fake()->sentence(),
|
||||
'picture_title' => fake()->sentence(),
|
||||
'published' => false,
|
||||
];
|
||||
}
|
||||
}
|
||||
22
database/factories/StampFactory.php
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class StampFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'picture_alt' => fake()->sentence(),
|
||||
'picture_title' => fake()->sentence(),
|
||||
'published' => fake()->boolean(75),
|
||||
];
|
||||
}
|
||||
}
|
||||
24
database/factories/TestimonialFactory.php
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?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()
|
||||
{
|
||||
return [
|
||||
'picture_alt' => fake()->sentence(),
|
||||
'picture_title' => fake()->sentence(),
|
||||
'description' => fake()->sentence(),
|
||||
'job' => fake()->jobTitle(),
|
||||
'statut' => fake()->word(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
BIN
database/factories/assets/homepages/default-picture-640x390.png
Normal file
|
After Width: | Height: | Size: 6.2 KiB |
BIN
database/factories/assets/news/default-picture-1002x565.png
Normal file
|
After Width: | Height: | Size: 7.4 KiB |
BIN
database/factories/assets/news/default-picture-265x354.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
database/factories/assets/products/default-picture-327x252.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
database/factories/assets/products/default-picture-332x252.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
database/factories/assets/products/default-picture-774x515.png
Normal file
|
After Width: | Height: | Size: 4.8 KiB |
BIN
database/factories/assets/ranges/default-picture-246x337.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
database/factories/assets/ranges/default-picture-332x442.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
database/factories/assets/ranges/default-picture-466x440.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
|
After Width: | Height: | Size: 4.9 KiB |
BIN
database/factories/assets/stamps/default-picture-120x120.png
Normal file
|
After Width: | Height: | Size: 720 B |
|
After Width: | Height: | Size: 3.2 KiB |
|
|
@ -13,7 +13,7 @@ return new class extends Migration
|
|||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('explorerpage_commitment', function (Blueprint $table) {
|
||||
Schema::create('commitment_explorerpage', function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('explorerpage_id');
|
||||
$table->unsignedBigInteger('commitment_id');
|
||||
});
|
||||
|
|
@ -26,6 +26,6 @@ return new class extends Migration
|
|||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('explorerpage_commitment');
|
||||
Schema::dropIfExists('commitment_explorerpage');
|
||||
}
|
||||
};
|
||||
|
|
@ -13,7 +13,7 @@ return new class extends Migration
|
|||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('product_commitment', function (Blueprint $table) {
|
||||
Schema::create('commitment_product', function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('product_id');
|
||||
$table->unsignedBigInteger('commitment_id');
|
||||
});
|
||||
|
|
@ -26,6 +26,6 @@ return new class extends Migration
|
|||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('product_commitment');
|
||||
Schema::dropIfExists('commitment_product');
|
||||
}
|
||||
};
|
||||
|
|
@ -15,13 +15,13 @@ return new class extends Migration
|
|||
{
|
||||
Schema::create('explorerpages', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('picture_1')->comment('Path de la première illustration');
|
||||
$table->string('picture_1')->comment('Path de la première illustration (265px * 364px');
|
||||
$table->string('picture_1_alt')->comment('Attribut alt de l\'image 1');
|
||||
$table->string('picture_1_title')->comment('Attribut title de l\'image 1');
|
||||
$table->string('picture_2')->comment('Path de la deuxième illustration');
|
||||
$table->string('picture_2')->comment('Path de la deuxième illustration (265px * 364px');
|
||||
$table->string('picture_2_alt')->comment('Attribut alt de l\'image 2');
|
||||
$table->string('picture_2_title')->comment('Attribut title de l\'image 2');
|
||||
$table->string('picture_3')->comment('Path de la troisième illustration');
|
||||
$table->string('picture_3')->comment('Path de la troisième illustration (265px * 364px');
|
||||
$table->string('picture_3_alt')->comment('Attribut alt de l\'image 3');
|
||||
$table->string('picture_3_title')->comment('Attribut title de l\'image 3');
|
||||
$table->timestamps();
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ return new class extends Migration
|
|||
->comment('Mode de cuisson (enum \\App\\Enums\\Products\\CookingModeEnum)');
|
||||
$table->text('cooking_advice')->comment('WYSIWYG - Conseil de réchauffage');
|
||||
$table->text('ingredients')->comment('WYSIWYG - Ingrédients qui composent le produit');
|
||||
$table->json('nutrionnal_values')->comment('JSON des valeurs nutritionnelles pour 100g');
|
||||
$table->json('nutritionnal_values')->comment('JSON des valeurs nutritionnelles pour 100g');
|
||||
$table->boolean('published')->comment('Le produit est-il visible ?');
|
||||
$table->unsignedInteger('order')->comment('Numéro permettant d\'ordonner les produits');
|
||||
$table->unsignedBigInteger('range_id');
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ return new class extends Migration
|
|||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('seasonal_section', function (Blueprint $table) {
|
||||
Schema::create('seasonal_sections', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('title')->comment('Titre de la section saisonnière');
|
||||
$table->text('text')->comment('WYSIWYG - Texte de la section saisonnière');
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
|
|
@ -11,18 +12,26 @@ return new class extends Migration
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('static_pages', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedTinyInteger('type')->unique()
|
||||
->comment('Type de la page (enum \\App\\Enums\\StaticPage\\PageTypeEnum)');
|
||||
$table->string('seo_title')->comment('Utilisé pour la balise title de la page');
|
||||
$table->string('seo_description')->comment('Utilisé pour la balise meta description de la page');
|
||||
$table->string('title')->comment('Utilisé pour la balise h1 de la page');
|
||||
$table->text('content')->comment('WYSIWYG - Contenu de la page. Peut être une chaîne vide selon le type');
|
||||
|
||||
$table->unsignedTinyInteger('type')->unique()->comment('Page type (StaticPageEnum)');
|
||||
|
||||
$table->string('seo_title')->comment('Seo title about 70 chars as recommended');
|
||||
$table->string('seo_description')->comment('Seo description about 160 chars as recommended');
|
||||
|
||||
$table->string('title')->comment('Title for the page');
|
||||
$table->string('slug')->unique()->comment('Unique title slug');
|
||||
|
||||
$table->text('content')->comment('WYSIWYG text content using ckeditor');
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
Artisan::call('db:seed', [
|
||||
'class' => 'StaticPageSeeder'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -30,7 +39,7 @@ return new class extends Migration
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('static_pages');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ return new class extends Migration
|
|||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('explorerpage_commitment', function (Blueprint $table) {
|
||||
Schema::table('commitment_explorerpage', function (Blueprint $table) {
|
||||
$table->foreign(['explorerpage_id'])->references(['id'])->on('explorerpages');
|
||||
$table->foreign(['commitment_id'])->references(['id'])->on('commitments');
|
||||
});
|
||||
|
|
@ -26,9 +26,9 @@ return new class extends Migration
|
|||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('explorerpage_commitment', function (Blueprint $table) {
|
||||
$table->dropForeign('explorerpage_commitment_explorerpage_id_foreign');
|
||||
$table->dropForeign('explorerpage_commitment_commitment_id_foreign');
|
||||
Schema::table('commitment_explorerpage', function (Blueprint $table) {
|
||||
$table->dropForeign('commitment_explorerpage_explorerpage_id_foreign');
|
||||
$table->dropForeign('commitment_explorerpage_commitment_id_foreign');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -13,7 +13,7 @@ return new class extends Migration
|
|||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('product_commitment', function (Blueprint $table) {
|
||||
Schema::table('commitment_product', function (Blueprint $table) {
|
||||
$table->foreign(['product_id'])->references(['id'])->on('products');
|
||||
$table->foreign(['commitment_id'])->references(['id'])->on('commitments');
|
||||
});
|
||||
|
|
@ -26,9 +26,9 @@ return new class extends Migration
|
|||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('product_commitment', function (Blueprint $table) {
|
||||
$table->dropForeign('product_commitment_product_id_foreign');
|
||||
$table->dropForeign('product_commitment_commitment_id_foreign');
|
||||
Schema::table('commitment_product', function (Blueprint $table) {
|
||||
$table->dropForeign('commitment_product_product_id_foreign');
|
||||
$table->dropForeign('commitment_product_commitment_id_foreign');
|
||||
});
|
||||
}
|
||||
};
|
||||
25
database/seeders/CommitmentSeeder.php
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Lib\Helpers\FileStorageHelper;
|
||||
use App\Models\Commitment;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class CommitmentSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
FileStorageHelper::removeModelFiles(new Commitment());
|
||||
Commitment::factory(12)->create([
|
||||
'picture' => FileStorageHelper::storeFile(new Commitment(), new \SplFileInfo(\resource_path(
|
||||
'../database/factories/assets/commitments/default-picture-185x185.png'
|
||||
)))
|
||||
]);
|
||||
}
|
||||
}
|
||||
25
database/seeders/ConvictionpageSeeder.php
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Convictionpage;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class ConvictionpageSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// Disable model events to allow Convictionpage creation in seeders.
|
||||
try {
|
||||
Convictionpage::unsetEventDispatcher();
|
||||
Convictionpage::factory(1)->create();
|
||||
} finally {
|
||||
Convictionpage::setEventDispatcher(new \Illuminate\Events\Dispatcher());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -15,6 +15,17 @@ class DatabaseSeeder extends Seeder
|
|||
{
|
||||
$this->call([
|
||||
UserSeeder::class,
|
||||
CommitmentSeeder::class,
|
||||
RangeSeeder::class,
|
||||
ProductSeeder::class,
|
||||
NewsSeeder::class,
|
||||
SeasonalSectionSeeder::class,
|
||||
StampSeeder::class,
|
||||
TestimonialSeeder::class,
|
||||
ConvictionpageSeeder::class,
|
||||
ExplorerpageSeeder::class,
|
||||
HomepageSeeder::class,
|
||||
JoinuspageSeeder::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
43
database/seeders/ExplorerpageSeeder.php
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Lib\Helpers\FileStorageHelper;
|
||||
use App\Models\Commitment;
|
||||
use App\Models\Explorerpage;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class ExplorerpageSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// Disable model events to allow Explorerpage creation in seeders.
|
||||
try {
|
||||
FileStorageHelper::removeModelFiles(new Explorerpage());
|
||||
Explorerpage::unsetEventDispatcher();
|
||||
Explorerpage::factory(1)->create([
|
||||
'picture_1' => FileStorageHelper::storeFile(new Explorerpage(), new \SplFileInfo(
|
||||
\resource_path('../database/factories/assets/explorerpages/default-picture-265x364.png')
|
||||
)),
|
||||
'picture_2' => FileStorageHelper::storeFile(new Explorerpage(), new \SplFileInfo(
|
||||
\resource_path('../database/factories/assets/explorerpages/default-picture-265x364.png')
|
||||
)),
|
||||
'picture_3' => FileStorageHelper::storeFile(new Explorerpage(), new \SplFileInfo(
|
||||
\resource_path('../database/factories/assets/explorerpages/default-picture-265x364.png')
|
||||
)),
|
||||
]);
|
||||
|
||||
$commitments = Commitment::query()->get();
|
||||
Explorerpage::query()->each(function (Explorerpage $explorerpage) use ($commitments) {
|
||||
$explorerpage->commitments()->saveMany($commitments->random(\rand(3, 12)));
|
||||
});
|
||||
} finally {
|
||||
Explorerpage::setEventDispatcher(new \Illuminate\Events\Dispatcher());
|
||||
} //end try
|
||||
}
|
||||
}
|
||||
31
database/seeders/HomepageSeeder.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Lib\Helpers\FileStorageHelper;
|
||||
use App\Models\Homepage;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class HomepageSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// Disable model events to allow Homepage creation in seeders.
|
||||
try {
|
||||
FileStorageHelper::removeModelFiles(new Homepage());
|
||||
Homepage::unsetEventDispatcher();
|
||||
Homepage::factory(1)->create([
|
||||
'picture' => FileStorageHelper::storeFile(new Homepage(), new \SplFileInfo(\resource_path(
|
||||
'../database/factories/assets/homepages/default-picture-640x390.png'
|
||||
))),
|
||||
]);
|
||||
} finally {
|
||||
Homepage::setEventDispatcher(new \Illuminate\Events\Dispatcher());
|
||||
}
|
||||
}
|
||||
}
|
||||
25
database/seeders/JoinuspageSeeder.php
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Joinuspage;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class JoinuspageSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// Disable model events to allow Joinuspage creation in seeders.
|
||||
try {
|
||||
Joinuspage::unsetEventDispatcher();
|
||||
Joinuspage::factory(1)->create();
|
||||
} finally {
|
||||
Joinuspage::setEventDispatcher(new \Illuminate\Events\Dispatcher());
|
||||
}
|
||||
}
|
||||
}
|
||||
28
database/seeders/NewsSeeder.php
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<?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)->create([
|
||||
'picture_thumbnail' => FileStorageHelper::storeFile(new News(), new \SplFileInfo(\resource_path(
|
||||
'../database/factories/assets/news/default-picture-265x354.png'
|
||||
))),
|
||||
'picture' => FileStorageHelper::storeFile(new News(), new \SplFileInfo(\resource_path(
|
||||
'../database/factories/assets/news/default-picture-1002x565.png'
|
||||
))),
|
||||
]);
|
||||
}
|
||||
}
|
||||
37
database/seeders/ProductSeeder.php
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Lib\Helpers\FileStorageHelper;
|
||||
use App\Models\Commitment;
|
||||
use App\Models\Product;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class ProductSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
FileStorageHelper::removeModelFiles(new Product());
|
||||
Product::factory(25)->create([
|
||||
'picture_thumbnail' => FileStorageHelper::storeFile(new Product(), new \SplFileInfo(\resource_path(
|
||||
'../database/factories/assets/products/default-picture-332x252.png'
|
||||
))),
|
||||
'picture_ambiance' => FileStorageHelper::storeFile(new Product(), new \SplFileInfo(\resource_path(
|
||||
'../database/factories/assets/products/default-picture-774x515.png'
|
||||
))),
|
||||
'picture_packshot' => FileStorageHelper::storeFile(new Product(), new \SplFileInfo(\resource_path(
|
||||
'../database/factories/assets/products/default-picture-327x252.png'
|
||||
)))
|
||||
]);
|
||||
|
||||
$commitments = Commitment::query()->get();
|
||||
Product::query()->each(function (Product $product) use ($commitments) {
|
||||
$product->commitments()->saveMany($commitments->random(\rand(0, 4)));
|
||||
});
|
||||
}
|
||||
}
|
||||
31
database/seeders/RangeSeeder.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Lib\Helpers\FileStorageHelper;
|
||||
use App\Models\Range;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class RangeSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
FileStorageHelper::removeModelFiles(new Range());
|
||||
Range::factory(10)->create([
|
||||
'picture' => FileStorageHelper::storeFile(new Range(), new \SplFileInfo(\resource_path(
|
||||
'../database/factories/assets/ranges/default-picture-466x440.png'
|
||||
))),
|
||||
'picture_productsheet' => FileStorageHelper::storeFile(new Range(), new \SplFileInfo(\resource_path(
|
||||
'../database/factories/assets/ranges/default-picture-332x442.png'
|
||||
))),
|
||||
'picture_thumbnail' => FileStorageHelper::storeFile(new Range(), new \SplFileInfo(\resource_path(
|
||||
'../database/factories/assets/ranges/default-picture-246x337.png'
|
||||
))),
|
||||
]);
|
||||
}
|
||||
}
|
||||
34
database/seeders/SeasonalSectionSeeder.php
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Enums\SeasonalSections\BackgroundEnum;
|
||||
use App\Lib\Helpers\FileStorageHelper;
|
||||
use App\Models\SeasonalSection;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class SeasonalSectionSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
FileStorageHelper::removeModelFiles(new SeasonalSection());
|
||||
$publish_at = now()->subDays(rand(1, 10));
|
||||
$unpublish_at = $publish_at->copy()->addDays(rand(10, 20));
|
||||
foreach (BackgroundEnum::cases() as $i => $background) {
|
||||
SeasonalSection::factory(1)->create([
|
||||
'background' => $background,
|
||||
'published' => $i === array_key_first(BackgroundEnum::cases()) ? true : false,
|
||||
'publish_at' => $publish_at->subMonths(),
|
||||
'unpublish_at' => $unpublish_at->subMonths(),
|
||||
'picture' => FileStorageHelper::storeFile(new SeasonalSection(), new \SplFileInfo(
|
||||
\resource_path('../database/factories/assets/seasonalsections/default-picture-362x542.png')
|
||||
)),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
25
database/seeders/StampSeeder.php
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Lib\Helpers\FileStorageHelper;
|
||||
use App\Models\Stamp;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class StampSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
FileStorageHelper::removeModelFiles(new Stamp());
|
||||
Stamp::factory(12)->create([
|
||||
'picture' => FileStorageHelper::storeFile(new Stamp(), new \SplFileInfo(
|
||||
\resource_path('../database/factories/assets/stamps/default-picture-120x120.png')
|
||||
)),
|
||||
]);
|
||||
}
|
||||
}
|
||||
155
database/seeders/StaticPageSeeder.php
Normal file
|
|
@ -0,0 +1,155 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Enums\StaticPageType;
|
||||
use App\Models\StaticPage;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class StaticPageSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
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' => '',
|
||||
]
|
||||
);
|
||||
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ée',
|
||||
'seo_description' => 'Seo description pour la page charte de confidentialitée',
|
||||
'title' => 'Charte de confidentialitée',
|
||||
'slug' => Str::slug('Charte de confidentialitée'),
|
||||
'type' => StaticPageType::confidentiality,
|
||||
'content' => \clean(\fake()->randomHtml(6, 7)),
|
||||
]
|
||||
);
|
||||
StaticPage::query()->updateOrCreate(
|
||||
[
|
||||
'type' => StaticPageType::home,
|
||||
],
|
||||
[
|
||||
'seo_title' => 'Seo title pour la page d\'accueil',
|
||||
'seo_description' => 'Seo description pour la page d\'accueil',
|
||||
'title' => 'Accueil',
|
||||
'slug' => Str::slug('Accueil'),
|
||||
'type' => StaticPageType::home,
|
||||
'content' => '',
|
||||
]
|
||||
);
|
||||
StaticPage::query()->updateOrCreate(
|
||||
[
|
||||
'type' => StaticPageType::conviction,
|
||||
],
|
||||
[
|
||||
'seo_title' => 'Seo title pour la page Nos Convictions',
|
||||
'seo_description' => 'Seo description pour la page Nos Convictions',
|
||||
'title' => 'Nos Convictions',
|
||||
'slug' => Str::slug('Nos Convictions'),
|
||||
'type' => StaticPageType::conviction,
|
||||
'content' => '',
|
||||
]
|
||||
);
|
||||
StaticPage::query()->updateOrCreate(
|
||||
[
|
||||
'type' => StaticPageType::explorer,
|
||||
],
|
||||
[
|
||||
'seo_title' => 'Seo title pour la page Explorateur & Gastronome',
|
||||
'seo_description' => 'Seo description pour la page Explorateur & Gastronome',
|
||||
'title' => 'Explorateur & Gastronome',
|
||||
'slug' => Str::slug('Explorateur & Gastronome'),
|
||||
'type' => StaticPageType::explorer,
|
||||
'content' => '',
|
||||
]
|
||||
);
|
||||
StaticPage::query()->updateOrCreate(
|
||||
[
|
||||
'type' => StaticPageType::joinus,
|
||||
],
|
||||
[
|
||||
'seo_title' => 'Seo title pour la page Rejoignez-nous',
|
||||
'seo_description' => 'Seo description pour la page Rejoignez-nous',
|
||||
'title' => 'Rejoignez-nous',
|
||||
'slug' => Str::slug('Rejoignez-nous'),
|
||||
'type' => StaticPageType::joinus,
|
||||
'content' => '',
|
||||
]
|
||||
);
|
||||
StaticPage::query()->updateOrCreate(
|
||||
[
|
||||
'type' => StaticPageType::ranges,
|
||||
],
|
||||
[
|
||||
'seo_title' => 'Seo title pour la page Nos Gammes de Produits',
|
||||
'seo_description' => 'Seo description pour la page Nos Gammes de Produits',
|
||||
'title' => 'Nos Gammes de Produits',
|
||||
'slug' => Str::slug('Nos Gammes de Produits'),
|
||||
'type' => StaticPageType::ranges,
|
||||
'content' => '',
|
||||
]
|
||||
);
|
||||
StaticPage::query()->updateOrCreate(
|
||||
[
|
||||
'type' => StaticPageType::aboutus,
|
||||
],
|
||||
[
|
||||
'seo_title' => 'Seo title pour la page Nous Connaître',
|
||||
'seo_description' => 'Seo description pour la page Nous Connaître',
|
||||
'title' => 'Nous Connaître',
|
||||
'slug' => Str::slug('Nous Connaître'),
|
||||
'type' => StaticPageType::aboutus,
|
||||
'content' => '',
|
||||
]
|
||||
);
|
||||
StaticPage::query()->updateOrCreate(
|
||||
[
|
||||
'type' => StaticPageType::news,
|
||||
],
|
||||
[
|
||||
'seo_title' => 'Seo title pour la page Actualités',
|
||||
'seo_description' => 'Seo description pour la page Actualités',
|
||||
'title' => 'Actualités',
|
||||
'slug' => Str::slug('Actualités'),
|
||||
'type' => StaticPageType::news,
|
||||
'content' => '',
|
||||
]
|
||||
);
|
||||
} finally {
|
||||
StaticPage::setEventDispatcher(new \Illuminate\Events\Dispatcher());
|
||||
} //end try
|
||||
}
|
||||
}
|
||||
25
database/seeders/TestimonialSeeder.php
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
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());
|
||||
Testimonial::factory(12)->create([
|
||||
'picture' => FileStorageHelper::storeFile(new Testimonial(), new \SplFileInfo(
|
||||
\resource_path('../database/factories/assets/testimonials/default-picture-292x417.png')
|
||||
)),
|
||||
]);
|
||||
}
|
||||
}
|
||||