diff --git a/app/Http/Controllers/Bo/NewsController.php b/app/Http/Controllers/Bo/NewsController.php
index def4e5eb..3e771a8b 100644
--- a/app/Http/Controllers/Bo/NewsController.php
+++ b/app/Http/Controllers/Bo/NewsController.php
@@ -71,7 +71,7 @@ class NewsController extends Controller
*/
public function create(News $news): \Illuminate\Contracts\View\View
{
- $newsCategoryModels = NewsCategory::query()->where('published', true)->orderBy('order')->get();
+ $newsCategoryModels = NewsCategory::getPublishedOrdered();
return view('bo.pages.news.create', ['newsModel' => $news, 'newsCategoryModels' => $newsCategoryModels]);
}
@@ -118,7 +118,7 @@ class NewsController extends Controller
*/
public function edit(News $news): \Illuminate\Contracts\View\View
{
- $newsCategoryModels = NewsCategory::query()->where('published', true)->orderBy('order')->get();
+ $newsCategoryModels = NewsCategory::getPublishedOrdered();
return view('bo.pages.news.edit', ['newsModel' => $news, 'newsCategoryModels' => $newsCategoryModels]);
}
diff --git a/app/Http/Controllers/Fo/BreedingController.php b/app/Http/Controllers/Fo/BreedingController.php
index 78d77fac..2aca4227 100644
--- a/app/Http/Controllers/Fo/BreedingController.php
+++ b/app/Http/Controllers/Fo/BreedingController.php
@@ -16,11 +16,7 @@ class BreedingController extends Controller
*/
public function breedingPage(StaticPage $staticPage): \Illuminate\Contracts\View\View
{
- $newsBreedingModels = NewsBreeding::query()
- ->where('associated_page', $staticPage->type)
- ->where('published', true)
- ->orderBy('order')
- ->get();
+ $newsBreedingModels = NewsBreeding::getPublishedOrderedForType($staticPage->type);
return view('fo.pages.breeding.show', [
'staticPageModel' => $staticPage,
'newsBreedingModels' => $newsBreedingModels,
diff --git a/app/Http/Controllers/Fo/HomeController.php b/app/Http/Controllers/Fo/HomeController.php
index a8be4e85..76027dcb 100644
--- a/app/Http/Controllers/Fo/HomeController.php
+++ b/app/Http/Controllers/Fo/HomeController.php
@@ -31,22 +31,15 @@ class HomeController extends Controller
*/
public function index(): \Illuminate\Contracts\View\View
{
- $staticPageModel = StaticPage::query()->where('type', StaticPageType::home)->first();
- $mainSlideModels = MainSlide::query()->where('published', true)->orderBy('order', 'ASC')
- ->with('approach')->get();
- $demarcheSlideModels = DemarcheSlide::query()->where('published', true)->orderBy('order', 'ASC')->get();
- $rangeModels = Range::query()->where('published', true)->orderBy('slug', 'ASC')->get();
+ $staticPageModel = StaticPage::getCachedStaticPage(StaticPageType::home);
+ $mainSlideModels = MainSlide::getPublishedOrderedWithApproaches();
+ $demarcheSlideModels = DemarcheSlide::getPublishedOrdered();
+ $rangeModels = Range::getPublishedOrderedBySlug();
$productViews = Product::getProductsViewsByRange();
- $hotNewsSettings = GeneralSetting::query()->where('type', SettingsType::hotNews)->first();
- $newsModels = News::query()->where('published', true)->with('newsCategory')->get();
- $recipeModels = Recipe::query()->where('published', true)->with([
- 'products',
- 'products.meat',
- 'products.submeat',
- 'consumptionMoment'
- ])->limit(9)->get();
- $videoModels = Video::query()->where('published', true)->where('is_on_homepage', true)
- ->orderBy('order')->with('product')->limit(9)->get();
+ $hotNewsSettings = GeneralSetting::getCachedGeneralSetting(SettingsType::hotNews);
+ $newsModels = News::getPublishedWithNewsCategory();
+ $recipeModels = Recipe::get9PublishedWithProducts();
+ $videoModels = Video::get9PublishedHomeVideosOrderedWithProducts();
$discountsTotal = Discount::query()->get()->sum('value');
return view('fo.pages.home', compact(
'staticPageModel',
diff --git a/app/Http/Controllers/Fo/NewsController.php b/app/Http/Controllers/Fo/NewsController.php
index 40765c62..fce09216 100644
--- a/app/Http/Controllers/Fo/NewsController.php
+++ b/app/Http/Controllers/Fo/NewsController.php
@@ -18,8 +18,8 @@ class NewsController extends Controller
*/
public function index(): \Illuminate\Contracts\View\View
{
- $staticPageModel = StaticPage::query()->where('type', StaticPageType::news)->first();
- $newsCategories = NewsCategory::query()->where('published', true)->orderByDesc('order')->get();
+ $staticPageModel = StaticPage::getCachedStaticPage(StaticPageType::news);
+ $newsCategories = NewsCategory::getPublishedOrdered();
return view('fo.pages.news.index', [
'newsViews' => News::getNewsViewsByNewsCategory(),
@@ -43,7 +43,7 @@ class NewsController extends Controller
->where([
['published', '=', true],
['id', '!=', $newsModel->id],
- ])
+ ])
->inRandomOrder()
->take(3)
->get();
@@ -51,7 +51,7 @@ class NewsController extends Controller
return view('fo.pages.news.show', [
'newsModel' => $newsModel,
'asideNewsModels' => $asideNewsModels
- ]);
+ ]);
}
/**
diff --git a/app/Http/Controllers/Fo/ProductController.php b/app/Http/Controllers/Fo/ProductController.php
index 74ef716d..5e9c3810 100644
--- a/app/Http/Controllers/Fo/ProductController.php
+++ b/app/Http/Controllers/Fo/ProductController.php
@@ -46,14 +46,12 @@ class ProductController extends Controller
->where('published', true)
->orderBy('slug')
->paginate($this->productModelsPerPage);
- $productDiscoverModels = Product::query()->where('published', true)->where('discover', true)->get();
- $staticPageModel = StaticPage::query()->where('type', StaticPageType::products)->first();
- $rangeModels = Range::query()->where('published', true)->with('subranges')->orderBy('order')->get();
- $subrangeModels = $subrangeModelsFiltered ?? Subrange::query()->where('published', true)
- ->orderBy('order')->get();
- $meatModels = Meat::query()->where('published', true)->with('submeats')->orderBy('order')->get();
- $submeatModels = $submeatModelsFiltered ?? Submeat::query()->where('published', true)
- ->orderBy('order')->get();
+ $productDiscoverModels = Product::getPublishedDiscovered();
+ $staticPageModel = StaticPage::getCachedStaticPage(StaticPageType::products);
+ $rangeModels = Range::getPublishedOrderedWithSubranges();
+ $subrangeModels = $subrangeModelsFiltered ?? Subrange::getPublishedOrdered();
+ $meatModels = Meat::getPublishedOrderedWithSubmeats();
+ $submeatModels = $submeatModelsFiltered ?? Submeat::getPublishedOrdered();
return view('fo.pages.products.index', [
'viewsPaginate' => $this->getViewsFromPaginateModels($productModels),
@@ -82,7 +80,7 @@ class ProductController extends Controller
}
$productModelSibling = $this->getSiblingModels($productModel);
- $staticPageModel = StaticPage::query()->where('type', StaticPageType::product)->first();
+ $staticPageModel = StaticPage::getCachedStaticPage(StaticPageType::product);
/** @var \App\Models\Recipe|null $recipeModel */
$recipeModel = $productModel->recipes->isNotEmpty()
diff --git a/app/Http/Controllers/Fo/RecipeController.php b/app/Http/Controllers/Fo/RecipeController.php
index f786bd44..b14fe22b 100644
--- a/app/Http/Controllers/Fo/RecipeController.php
+++ b/app/Http/Controllers/Fo/RecipeController.php
@@ -43,12 +43,12 @@ class RecipeController extends Controller
->where('published', true)
->orderBy('slug')
->paginate($this->recipeModelsPerPage);
- $recipeModel = Recipe::query()->where('published', true)->where('highlight', true)->first();
- $staticPageModel = StaticPage::query()->where('type', StaticPageType::recipes)->first();
- $consumptionMomentModels = ConsumptionMoment::query()->orderBy('slug')->get();
- $meatModels = Meat::query()->where('published', true)->with('submeats')->orderBy('order')->get();
+ $recipeModel = Recipe::getFirstHighlighted();
+ $staticPageModel = StaticPage::getCachedStaticPage(StaticPageType::recipes);
+ $consumptionMomentModels = ConsumptionMoment::getOrderedBySlug();
+ $meatModels = Meat::getPublishedOrderedWithSubmeats();
$submeatModels = $submeatModelsFiltered ??
- Submeat::query()->where('published', true)->orderBy('order')->get();
+ Submeat::publishedSubmeatsOrderedByOrder();
return view('fo.pages.recipes.index', [
'viewsPaginate' => $this->getViewsFromPaginateModels($recipeModels),
@@ -79,7 +79,7 @@ class RecipeController extends Controller
abort(404);
}
- $staticPageModel = StaticPage::query()->where('type', StaticPageType::recipe)->first();
+ $staticPageModel = StaticPage::getCachedStaticPage(StaticPageType::recipe);
return view('fo.pages.recipes.show', [
'recipeModel' => $recipeModel,
diff --git a/app/Http/Controllers/Fo/StaticPageController.php b/app/Http/Controllers/Fo/StaticPageController.php
index 63bcdde8..67f936c7 100644
--- a/app/Http/Controllers/Fo/StaticPageController.php
+++ b/app/Http/Controllers/Fo/StaticPageController.php
@@ -28,7 +28,7 @@ class StaticPageController extends Controller
*/
public function contact(StaticPage $staticPageModel): \Illuminate\Contracts\View\View
{
- $staticPageModel = StaticPage::query()->where('type', StaticPageType::contact)->first();
+ $staticPageModel = StaticPage::getCachedStaticPage(StaticPageType::contact);
return view('fo.pages.legals', ['staticPageModel' => $staticPageModel]);
}
@@ -40,7 +40,7 @@ class StaticPageController extends Controller
*/
public function legals(StaticPage $staticPageModel): \Illuminate\Contracts\View\View
{
- $staticPageModel = StaticPage::query()->where('type', StaticPageType::legals)->first();
+ $staticPageModel = StaticPage::getCachedStaticPage(StaticPageType::legals);
return view('fo.pages.legals', ['staticPageModel' => $staticPageModel]);
}
@@ -52,7 +52,7 @@ class StaticPageController extends Controller
*/
public function policies(StaticPage $staticPageModel): \Illuminate\Contracts\View\View
{
- $staticPageModel = StaticPage::query()->where('type', StaticPageType::confidentiality)->first();
+ $staticPageModel = StaticPage::getCachedStaticPage(StaticPageType::confidentiality);
return view('fo.pages.legals', ['staticPageModel' => $staticPageModel]);
}
@@ -64,7 +64,7 @@ class StaticPageController extends Controller
*/
public function selling(StaticPage $staticPageModel): \Illuminate\Contracts\View\View
{
- $staticPageModel = StaticPage::query()->where('type', StaticPageType::selling)->first();
+ $staticPageModel = StaticPage::getCachedStaticPage(StaticPageType::selling);
return view('fo.pages.legals', ['staticPageModel' => $staticPageModel]);
}
@@ -76,7 +76,7 @@ class StaticPageController extends Controller
*/
public function accessibility(StaticPage $staticPageModel): \Illuminate\Contracts\View\View
{
- $staticPageModel = StaticPage::query()->where('type', StaticPageType::accessibility)->first();
+ $staticPageModel = StaticPage::getCachedStaticPage(StaticPageType::accessibility);
return view('fo.pages.legals', ['staticPageModel' => $staticPageModel]);
}
@@ -89,23 +89,22 @@ class StaticPageController extends Controller
public function recruitment(StaticPage $staticPageModel): \Illuminate\Contracts\View\View
{
$detect = new MobileDetect();
- $staticPageModel = StaticPage::query()->where('type', StaticPageType::recruitment)->first();
+ $staticPageModel = StaticPage::getCachedStaticPage(StaticPageType::recruitment);
$offerModels = Cache::rememberForever(
config('services.digital_recruiter.url'),
fn() => Offer::query()->where('published', true)->orderBy('publish_at', 'DESC')->take(6)->get()
);
- $professionModels = Profession::query()->where('published', true)->take(5)->get();
- $brandAdvantageModels = BrandAdvantage::query()->where('published', true)->orderBy('order')->get();
- $newsCorporateModels = NewsCorporate::query()
- ->where('published', true)
- ->orderByDesc('updated_at')
- ->limit($detect->isMobile() ? 3 : 9)
- ->get();
+ $professionModels = Profession::get5Published();
+ $brandAdvantageModels = BrandAdvantage::getPublishedOrdered();
+ $newsCorporateModels = NewsCorporate::get9PublishedOrderedByUpdatedAt();
+ if ($detect->isMobile()) {
+ $newsCorporateModels = $newsCorporateModels->take(3);
+ }
$digitalRecruiterCount = Cache::rememberForever(
sprintf('%s-count', config('services.digital_recruiter.url')),
fn() => GeneralSetting::query()->where('type', SettingsType::offersCount)->firstOrFail()->value['count']
);
- $testimonialModels = Testimonial::query()->where('published', true)->get();
+ $testimonialModels = Testimonial::getPublishedOrdered();
return view('fo.pages.recruitment', compact(
'staticPageModel',
'offerModels',
@@ -126,9 +125,9 @@ class StaticPageController extends Controller
*/
public function story(StaticPage $staticPageModel): \Illuminate\Contracts\View\View
{
- $staticPageModel = StaticPage::query()->where('type', StaticPageType::story)->first();
- $keyNumberModels = KeyNumber::query()->where('published', true)->orderBy('order')->take(5)->get();
- $historicalMilestoneModels = HistoricalMilestone::query()->where('published', true)->orderBy('year')->get();
+ $staticPageModel = StaticPage::getCachedStaticPage(StaticPageType::story);
+ $keyNumberModels = KeyNumber::get5PublishedOrdered();
+ $historicalMilestoneModels = HistoricalMilestone::getPublishedOrderedByYear();
return view('fo.pages.story', compact('staticPageModel', 'keyNumberModels', 'historicalMilestoneModels'));
}
@@ -140,8 +139,8 @@ class StaticPageController extends Controller
*/
public function saga(StaticPage $staticPageModel)
{
- $staticPageModel = StaticPage::query()->where('type', StaticPageType::saga)->first();
- $videoModels = Video::query()->where('published', true)->orderBy('order')->with('product')->take(6)->get();
+ $staticPageModel = StaticPage::getCachedStaticPage(StaticPageType::saga);
+ $videoModels = Video::get6PublishedVideosOrderedWithProducts();
return view('fo.pages.saga', compact('staticPageModel', 'videoModels'));
}
}
diff --git a/app/Models/BrandAdvantage.php b/app/Models/BrandAdvantage.php
index f935eb68..11ddeed9 100644
--- a/app/Models/BrandAdvantage.php
+++ b/app/Models/BrandAdvantage.php
@@ -6,6 +6,7 @@ use App\Lib\Helpers\FileStorageHelper;
use App\Traits\Models\ActivityLog;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\Facades\Cache;
/**
* @property string $title Title.
@@ -63,14 +64,19 @@ class BrandAdvantage extends Model
self::setOrder($model);
self::manageFields($model);
});
+ static::created(function (self $model) {
+ self::resetCache();
+ });
static::updating(function (self $model) {
self::manageFields($model);
});
static::updated(function (self $model) {
FileStorageHelper::removeOldFile($model, 'picto');
+ self::resetCache();
});
static::deleted(function (self $model) {
FileStorageHelper::removeFile($model, 'picto');
+ self::resetCache();
});
}
@@ -124,4 +130,25 @@ class BrandAdvantage extends Model
{
return \boolval($this->getOriginal('published')) !== $this->published ? true : false;
}
+
+ /**
+ * Reset all cache elements related to this model.
+ * @return void
+ */
+ private static function resetCache()
+ {
+ Cache::forget('publishedBrandAdvantagesOrderedByOrder');
+ self::getPublishedOrdered();
+ }
+
+ /**
+ * Get all published BrandAdvantages ordered by order.
+ * @return \Illuminate\Database\Eloquent\Collection
+ */
+ public static function getPublishedOrdered(): \Illuminate\Database\Eloquent\Collection
+ {
+ return Cache::rememberForever('publishedBrandAdvantagesOrderedByOrder', function () {
+ return self::query()->where('published', true)->orderBy('order')->get();
+ });
+ }
}
diff --git a/app/Models/ConsumptionMoment.php b/app/Models/ConsumptionMoment.php
index 902c90bf..7347ddcd 100644
--- a/app/Models/ConsumptionMoment.php
+++ b/app/Models/ConsumptionMoment.php
@@ -7,6 +7,7 @@ use App\Lib\Helpers\FileStorageHelper;
use App\Traits\Models\ActivityLog;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\Facades\Cache;
/**
* @property string $title Consumption moment title.
@@ -50,6 +51,9 @@ class ConsumptionMoment extends Model
$model->slug = str($model->title)->slug();
$model->picture = FileStorageHelper::storeFile($model, $model->picture, true);
});
+ static::created(function (self $model) {
+ self::resetCache();
+ });
static::updating(function (self $model) {
self::assertTitleIsUnique($model->title, $model->getKey());
$model->slug = str($model->title)->slug();
@@ -57,9 +61,11 @@ class ConsumptionMoment extends Model
});
static::updated(function (self $model) {
FileStorageHelper::removeOldFile($model, 'picture');
+ self::resetCache();
});
static::deleted(function (self $model) {
FileStorageHelper::removeFile($model, 'picture');
+ self::resetCache();
});
}
@@ -79,4 +85,25 @@ class ConsumptionMoment extends Model
ToolboxHelper::assertFieldIsUnique($table, 'title', $title, $id);
ToolboxHelper::assertFieldIsUnique($table, 'slug', str($title)->slug(), $id);
}
+
+ /**
+ * Reset all cache elements related to this model.
+ * @return void
+ */
+ private static function resetCache()
+ {
+ Cache::forget('consumptionMomentsOrderedBySlug');
+ self::getOrderedBySlug();
+ }
+
+ /**
+ * Get all consumption moments ordered by slug.
+ * @return \Illuminate\Database\Eloquent\Collection
+ */
+ public static function getOrderedBySlug(): \Illuminate\Database\Eloquent\Collection
+ {
+ return Cache::rememberForever('consumptionMomentsOrderedBySlug', function () {
+ return self::query()->orderBy('slug')->get();
+ });
+ }
}
diff --git a/app/Models/DemarcheSlide.php b/app/Models/DemarcheSlide.php
index 97b8c3f2..6b4be201 100644
--- a/app/Models/DemarcheSlide.php
+++ b/app/Models/DemarcheSlide.php
@@ -6,6 +6,7 @@ use App\Lib\Helpers\FileStorageHelper;
use App\Traits\Models\ActivityLog;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\Facades\Cache;
/**
* @property string $title Slide title.
@@ -85,6 +86,9 @@ class DemarcheSlide extends Model
self::setButtons($demarcheSlide);
$demarcheSlide->picture = FileStorageHelper::storeFile($demarcheSlide, $demarcheSlide->picture, true);
});
+ static::created(function (self $demarcheSlide) {
+ self::resetCache();
+ });
static::updating(function (self $demarcheSlide) {
self::makeStatusSense($demarcheSlide);
self::setButtons($demarcheSlide);
@@ -92,9 +96,11 @@ class DemarcheSlide extends Model
});
static::updated(function (self $demarcheSlide) {
FileStorageHelper::removeOldFile($demarcheSlide, 'picture');
+ self::resetCache();
});
static::deleted(function (self $demarcheSlide) {
FileStorageHelper::removeFile($demarcheSlide, 'picture');
+ self::resetCache();
});
}
@@ -177,4 +183,28 @@ class DemarcheSlide extends Model
{
$demarcheSlide->order = \intval(self::query()->max('order')) + 1;
}
+
+ /**
+ * Reset all cache elements related to this model.
+ * @return void
+ */
+ private static function resetCache()
+ {
+ Cache::forget('publishedDemarcheSlidesOrderedByOrder');
+ self::getPublishedOrdered();
+ }
+
+ /**
+ * Get all published demarche slides ordered by order.
+ * @return \Illuminate\Database\Eloquent\Collection
+ */
+ public static function getPublishedOrdered(): \Illuminate\Database\Eloquent\Collection
+ {
+ return Cache::rememberForever('publishedDemarcheSlidesOrderedByOrder', function () {
+ return self::query()
+ ->where('published', true)
+ ->orderBy('order')
+ ->get();
+ });
+ }
}
diff --git a/app/Models/GeneralSetting.php b/app/Models/GeneralSetting.php
index e7570497..3cfb81f4 100644
--- a/app/Models/GeneralSetting.php
+++ b/app/Models/GeneralSetting.php
@@ -11,6 +11,7 @@ use App\Traits\Models\IsCachedAsCollection;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Arr;
+use Illuminate\Support\Facades\Cache;
/**
* @property-read \App\Enums\Settings\SettingsType $type Enum SettingsType.
@@ -80,6 +81,7 @@ class GeneralSetting extends Model
);
}
self::removeCached();
+ self::resetCache($model->type);
});
static::deleting(fn() => throw new \ErrorException('Not allowed to create an instance of this'));
}
@@ -188,4 +190,27 @@ class GeneralSetting extends Model
default => throw new \ErrorException("No instruction to unserialize setting type '{$type->label()}'")
};
}
+
+ /**
+ * Reset all cache elements related to this model.
+ * @return void
+ */
+ private static function resetCache(SettingsType $type)
+ {
+ Cache::forget(sprintf('%sStaticPage', $type->name));
+ self::getCachedGeneralSetting($type);
+ }
+
+ /**
+ * Get cached general setting associated to a given type.
+ * @param \App\Enums\Settings\SettingsType $type
+ * @return \App\Models\StaticPage
+ */
+ public static function getCachedGeneralSetting(SettingsType $type)
+ {
+ return Cache::rememberForever(
+ sprintf('%sGeneralSetting', $type->name),
+ fn() => self::query()->where('type', $type)->first()
+ );
+ }
}
diff --git a/app/Models/HistoricalMilestone.php b/app/Models/HistoricalMilestone.php
index dce84cd1..00ed21e6 100644
--- a/app/Models/HistoricalMilestone.php
+++ b/app/Models/HistoricalMilestone.php
@@ -6,6 +6,7 @@ use App\Lib\Helpers\FileStorageHelper;
use App\Traits\Models\ActivityLog;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\Facades\Cache;
/**
* @property \Carbon\Carbon $year Historical milestone year.
@@ -67,6 +68,9 @@ class HistoricalMilestone extends Model
self::setImage($historicalMilestone, 'picture');
self::setImage($historicalMilestone, 'picto');
});
+ static::created(function (self $historicalMilestone) {
+ self::resetCache();
+ });
static::updating(function (self $historicalMilestone) {
self::setImage($historicalMilestone, 'picture');
self::setImage($historicalMilestone, 'picto');
@@ -74,10 +78,12 @@ class HistoricalMilestone extends Model
static::updated(function (self $historicalMilestone) {
FileStorageHelper::removeOldFile($historicalMilestone, 'picture');
FileStorageHelper::removeOldFile($historicalMilestone, 'picto');
+ self::resetCache();
});
static::deleted(function (self $historicalMilestone) {
FileStorageHelper::removeFile($historicalMilestone, 'picture');
FileStorageHelper::removeFile($historicalMilestone, 'picto');
+ self::resetCache();
});
}
@@ -103,4 +109,25 @@ class HistoricalMilestone extends Model
);
}
}
+
+ /**
+ * Reset all cache elements related to this model.
+ * @return void
+ */
+ private static function resetCache()
+ {
+ Cache::forget('publishedHistoricalMilestonesOrderedByYear');
+ self::getPublishedOrderedByYear();
+ }
+
+ /**
+ * Get all published HistoricalMilestones ordered by year.
+ * @return \Illuminate\Database\Eloquent\Collection
+ */
+ public static function getPublishedOrderedByYear(): \Illuminate\Database\Eloquent\Collection
+ {
+ return Cache::rememberForever('publishedHistoricalMilestonesOrderedByYear', function () {
+ return self::query()->where('published', true)->orderBy('year')->get();
+ });
+ }
}
diff --git a/app/Models/KeyNumber.php b/app/Models/KeyNumber.php
index 1da3eb52..c0949560 100644
--- a/app/Models/KeyNumber.php
+++ b/app/Models/KeyNumber.php
@@ -6,6 +6,7 @@ use App\Lib\Helpers\FileStorageHelper;
use App\Traits\Models\ActivityLog;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\Facades\Cache;
/**
* @property string $picto Picto path.
@@ -49,14 +50,19 @@ class KeyNumber extends Model
self::setOrder($keyNumber);
$keyNumber->picto = FileStorageHelper::storeFile($keyNumber, $keyNumber->picto, true);
});
+ static::created(function (self $keyNumber) {
+ self::resetCache();
+ });
static::updating(function (self $keyNumber) {
$keyNumber->picto = FileStorageHelper::storeFile($keyNumber, $keyNumber->picto, true);
});
static::updated(function (self $keyNumber) {
FileStorageHelper::removeOldFile($keyNumber, 'picto');
+ self::resetCache();
});
static::deleted(function (self $keyNumber) {
FileStorageHelper::removeFile($keyNumber, 'picto');
+ self::resetCache();
});
}
@@ -72,4 +78,25 @@ class KeyNumber extends Model
{
$model->order = \intval(self::query()->max('order')) + 1;
}
+
+ /**
+ * Reset all cache elements related to this model.
+ * @return void
+ */
+ private static function resetCache()
+ {
+ Cache::forget('5publishedKeyNumbersOrderedByOrder');
+ self::get5PublishedOrdered();
+ }
+
+ /**
+ * Get 5 published key numbers ordered by order.
+ * @return \Illuminate\Database\Eloquent\Collection
+ */
+ public static function get5PublishedOrdered(): \Illuminate\Database\Eloquent\Collection
+ {
+ return Cache::rememberForever('5publishedKeyNumbersOrderedByOrder', function () {
+ return self::query()->where('published', true)->orderBy('order')->take(5)->get();
+ });
+ }
}
diff --git a/app/Models/MainSlide.php b/app/Models/MainSlide.php
index 45eb0fde..40613da2 100644
--- a/app/Models/MainSlide.php
+++ b/app/Models/MainSlide.php
@@ -7,6 +7,7 @@ use App\Lib\Helpers\FileStorageHelper;
use App\Traits\Models\ActivityLog;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\Facades\Cache;
/**
* @property string $title Slide title.
@@ -112,6 +113,9 @@ class MainSlide extends Model
self::setImage($mainSlide);
$mainSlide->background = FileStorageHelper::storeFile($mainSlide, $mainSlide->background, true);
});
+ static::created(function (self $mainSlide) {
+ self::resetCache();
+ });
static::updating(function (self $mainSlide) {
self::makeStatusSense($mainSlide);
self::setButtons($mainSlide);
@@ -121,10 +125,12 @@ class MainSlide extends Model
static::updated(function (self $mainSlide) {
FileStorageHelper::removeOldFile($mainSlide, 'background');
FileStorageHelper::removeOldFile($mainSlide, 'picture');
+ self::resetCache();
});
static::deleted(function (self $mainSlide) {
FileStorageHelper::removeFile($mainSlide, 'background');
FileStorageHelper::removeFile($mainSlide, 'picture');
+ self::resetCache();
});
}
@@ -228,6 +234,31 @@ class MainSlide extends Model
$mainSlide->order = \intval(self::query()->max('order')) + 1;
}
+ /**
+ * Reset all cache elements related to this model.
+ * @return void
+ */
+ private static function resetCache()
+ {
+ Cache::forget('publishedMainSlidesOrderedByOrderWithApproaches');
+ self::getPublishedOrderedWithApproaches();
+ }
+
+ /**
+ * Get all published main slides ordered by order with approaches.
+ * @return \Illuminate\Database\Eloquent\Collection
+ */
+ public static function getPublishedOrderedWithApproaches(): \Illuminate\Database\Eloquent\Collection
+ {
+ return Cache::rememberForever('publishedMainSlidesOrderedByOrderWithApproaches', function () {
+ return self::query()
+ ->where('published', true)
+ ->orderBy('order')
+ ->with('approach')
+ ->get();
+ });
+ }
+
// * RELATIONSHIPS
/**
diff --git a/app/Models/Meat.php b/app/Models/Meat.php
index aa6af6d3..46d44f55 100644
--- a/app/Models/Meat.php
+++ b/app/Models/Meat.php
@@ -8,6 +8,7 @@ use App\Lib\Helpers\ToolboxHelper;
use App\Traits\Models\ActivityLog;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;
/**
@@ -80,6 +81,9 @@ class Meat extends Model
self::setOrder($model);
self::manageFields($model);
});
+ static::created(function (self $model) {
+ self::resetCache();
+ });
static::updating(function (self $model) {
// * ASSERTIONS
self::assertLabelIsUnique($model->label, $model->getKey());
@@ -89,6 +93,7 @@ class Meat extends Model
static::updated(function (self $model) {
FileStorageHelper::removeOldFile($model, 'banner');
FileStorageHelper::removeOldFile($model, 'picture');
+ self::resetCache();
});
static::deleting(function (self $model) {
/** @var \Illuminate\Database\Eloquent\Collection $submeats */
@@ -102,6 +107,7 @@ class Meat extends Model
static::deleted(function (self $model) {
FileStorageHelper::removeFile($model, 'banner');
FileStorageHelper::removeFile($model, 'picture');
+ self::resetCache();
});
}
@@ -146,6 +152,44 @@ class Meat extends Model
$model->order = \intval(self::query()->max('order')) + 1;
}
+ /**
+ * Reset all cache elements related to this model.
+ * @return void
+ */
+ private static function resetCache()
+ {
+ Cache::forget('publishedMeatsOrderedByOrder');
+ self::getPublishedOrdered();
+ Cache::forget('publishedMeatsOrderedByOrderWithSubmeats');
+ self::getPublishedOrderedWithSubmeats();
+ }
+
+ /**
+ * Get all published Meats ordered by order.
+ * @return \Illuminate\Database\Eloquent\Collection
+ */
+ public static function getPublishedOrdered(): \Illuminate\Database\Eloquent\Collection
+ {
+ return Cache::rememberForever('publishedMeatsOrderedByOrder', function () {
+ return self::query()->where('published', true)->orderBy('order')->get();
+ });
+ }
+
+ /**
+ * Get all published Meats ordered by order with submeats.
+ * @return \Illuminate\Database\Eloquent\Collection
+ */
+ public static function getPublishedOrderedWithSubmeats(): \Illuminate\Database\Eloquent\Collection
+ {
+ return Cache::rememberForever('publishedMeatsOrderedByOrderWithSubmeats', function () {
+ return self::query()
+ ->where('published', true)
+ ->with('submeats')
+ ->orderBy('order')
+ ->get();
+ });
+ }
+
// * RELATIONSHIPS
/**
diff --git a/app/Models/News.php b/app/Models/News.php
index 7079fe43..c74d2b4f 100644
--- a/app/Models/News.php
+++ b/app/Models/News.php
@@ -9,6 +9,7 @@ use Detection\MobileDetect;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Str;
@@ -88,6 +89,9 @@ class News extends Model
self::assertTitleIsUnique($news->title);
self::manageFields($news);
});
+ static::created(function (self $news) {
+ self::resetCache();
+ });
static::updating(function (self $news) {
self::makeStatusSense($news);
self::checkHighlightField($news);
@@ -97,11 +101,13 @@ class News extends Model
FileStorageHelper::removeOldFile($news, 'picture');
FileStorageHelper::removeOldFile($news, 'thumbnail');
FileStorageHelper::removeOldModelFilesFromHtml($news->content, $news->getOriginal("content"));
+ self::resetCache();
});
static::deleted(function (self $news) {
FileStorageHelper::removeFile($news, 'picture');
FileStorageHelper::removeFile($news, 'thumbnail');
FileStorageHelper::removeOldModelFilesFromHtml($news->content, $news->getOriginal("content"));
+ self::resetCache();
});
}
@@ -211,6 +217,27 @@ class News extends Model
ToolboxHelper::assertFieldIsUnique($table, 'slug', str($title)->slug(), $id);
}
+ /**
+ * Reset all cache elements related to this model.
+ * @return void
+ */
+ private static function resetCache()
+ {
+ Cache::forget('publishedNewsWithCategories');
+ self::getPublishedWithNewsCategory();
+ }
+
+ /**
+ * Get all published news with categories relations.
+ * @return \Illuminate\Database\Eloquent\Collection
+ */
+ public static function getPublishedWithNewsCategory(): \Illuminate\Database\Eloquent\Collection
+ {
+ return Cache::rememberForever('publishedNewsWithCategories', function () {
+ return self::query()->where('published', true)->with('newsCategory')->get();
+ });
+ }
+
/**
* Get News views by News category.
*
diff --git a/app/Models/NewsBreeding.php b/app/Models/NewsBreeding.php
index b6f07cb7..ec9e49d8 100644
--- a/app/Models/NewsBreeding.php
+++ b/app/Models/NewsBreeding.php
@@ -8,6 +8,7 @@ use App\Lib\Helpers\ToolboxHelper;
use App\Traits\Models\ActivityLog;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;
/**
@@ -76,14 +77,19 @@ class NewsBreeding extends Model
self::setOrder($model);
self::manageFields($model);
});
+ static::created(function (self $model) {
+ self::resetCache($model->associated_page);
+ });
static::updating(function (self $model) {
self::manageFields($model);
});
static::updated(function (self $model) {
FileStorageHelper::removeOldFile($model, 'picture');
+ self::resetCache($model->associated_page);
});
static::deleted(function (self $model) {
FileStorageHelper::removeFile($model, 'picture');
+ self::resetCache($model->associated_page);
});
}
@@ -177,6 +183,33 @@ class NewsBreeding extends Model
return false;
}
+ /**
+ * Reset all cache elements related to this model.
+ * @return void
+ */
+ private static function resetCache(StaticPageType $type)
+ {
+ Cache::forget(sprintf('%sPublishedNewsBreedingOrderedByOrder', $type->name));
+ self::getPublishedOrderedForType($type);
+ }
+
+ /**
+ * Get all published news breeding ordered by order associated to a given static page type.
+ * @return \Illuminate\Database\Eloquent\Collection
+ */
+ public static function getPublishedOrderedForType(StaticPageType $type): \Illuminate\Database\Eloquent\Collection
+ {
+ return Cache::rememberForever(
+ sprintf('%sPublishedNewsBreedingOrderedByOrder', $type->name),
+ fn() =>
+ self::query()
+ ->where('associated_page', $type)
+ ->where('published', true)
+ ->orderBy('order')
+ ->get()
+ );
+ }
+
// * RELATIONSHIPS
/**
diff --git a/app/Models/NewsCategory.php b/app/Models/NewsCategory.php
index c94839b2..b06ba54e 100644
--- a/app/Models/NewsCategory.php
+++ b/app/Models/NewsCategory.php
@@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
use App\Lib\Helpers\ToolboxHelper;
+use Illuminate\Support\Facades\Cache;
/**
* @property string $title The title of the news.
@@ -56,10 +57,19 @@ class NewsCategory extends Model
self::setOrder($newsCategory);
self::manageFields($newsCategory);
});
+ static::created(function (self $newsCategory) {
+ self::resetCache();
+ });
static::updating(function (self $newsCategory) {
self::assertTitleIsUnique($newsCategory->title, $newsCategory->getKey());
self::manageFields($newsCategory);
});
+ static::updated(function (self $newsCategory) {
+ self::resetCache();
+ });
+ static::deleted(function (self $newsCategory) {
+ self::resetCache();
+ });
}
// * METHODS
@@ -100,4 +110,25 @@ class NewsCategory extends Model
ToolboxHelper::assertFieldIsUnique($table, 'title', $title, $id);
ToolboxHelper::assertFieldIsUnique($table, 'slug', Str::slug($title), $id);
}
+
+ /**
+ * Reset all cache elements related to this model.
+ * @return void
+ */
+ private static function resetCache()
+ {
+ Cache::forget('publishedNewsCategoriesOrderedByOrder');
+ self::getPublishedOrdered();
+ }
+
+ /**
+ * Get all published NewsCategories ordered by order.
+ * @return \Illuminate\Database\Eloquent\Collection
+ */
+ public static function getPublishedOrdered(): \Illuminate\Database\Eloquent\Collection
+ {
+ return Cache::rememberForever('publishedNewsCategoriesOrderedByOrder', function () {
+ return self::query()->where('published', true)->orderBy('order')->get();
+ });
+ }
}
diff --git a/app/Models/NewsCorporate.php b/app/Models/NewsCorporate.php
index b52200cc..19740c8d 100644
--- a/app/Models/NewsCorporate.php
+++ b/app/Models/NewsCorporate.php
@@ -6,6 +6,7 @@ use App\Lib\Helpers\FileStorageHelper;
use App\Traits\Models\ActivityLog;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\Facades\Cache;
/**
* @property string $title The title of the news.
@@ -64,15 +65,20 @@ class NewsCorporate extends Model
self::makeStatusSense($newsCorporate);
$newsCorporate->picture = FileStorageHelper::storeFile($newsCorporate, $newsCorporate->picture, true);
});
+ static::created(function (self $newsCorporate) {
+ self::resetCache();
+ });
static::updating(function (self $newsCorporate) {
self::makeStatusSense($newsCorporate);
$newsCorporate->picture = FileStorageHelper::storeFile($newsCorporate, $newsCorporate->picture, true);
});
static::updated(function (self $newsCorporate) {
FileStorageHelper::removeOldFile($newsCorporate, 'picture');
+ self::resetCache();
});
static::deleted(function (self $newsCorporate) {
FileStorageHelper::removeFile($newsCorporate, 'picture');
+ self::resetCache();
});
}
@@ -124,4 +130,29 @@ class NewsCorporate extends Model
}
return false;
}
+
+ /**
+ * Reset all cache elements related to this model.
+ * @return void
+ */
+ private static function resetCache()
+ {
+ Cache::forget('9publishedNewsCorporateOrderedByUpdatedAt');
+ self::get9PublishedOrderedByUpdatedAt();
+ }
+
+ /**
+ * Get 9 published news corporate ordered by updated_at.
+ * @return \Illuminate\Database\Eloquent\Collection
+ */
+ public static function get9PublishedOrderedByUpdatedAt(): \Illuminate\Database\Eloquent\Collection
+ {
+ return Cache::rememberForever('9publishedNewsCorporateOrderedByUpdatedAt', function () {
+ return self::query()
+ ->where('published', true)
+ ->orderByDesc('updated_at')
+ ->limit(9)
+ ->get();
+ });
+ }
}
diff --git a/app/Models/Product.php b/app/Models/Product.php
index 5105f44c..e1f62ece 100644
--- a/app/Models/Product.php
+++ b/app/Models/Product.php
@@ -9,6 +9,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
use Illuminate\Database\Eloquent\Builder;
+use Illuminate\Support\Facades\Cache;
use Uwil\Seo\Laravel\Interfaces\SeoInterface;
use Uwil\Seo\Laravel\Traits\SeoTrait;
use Uwil\Seo\Laravel\Objects\SeoItem;
@@ -104,6 +105,9 @@ class Product extends Model implements SeoInterface
self::assertLabelIsUnique($product->label);
self::manageFields($product);
});
+ static::created(function (self $product) {
+ self::resetCache();
+ });
static::updating(function (self $product) {
self::assertLabelIsUnique($product->label, $product->getKey());
self::manageFields($product);
@@ -112,11 +116,13 @@ class Product extends Model implements SeoInterface
FileStorageHelper::removeOldFile($product, 'picture');
FileStorageHelper::removeOldFile($product, 'banner');
FileStorageHelper::removeOldFile($product, 'packaging');
+ self::resetCache();
});
static::deleted(function (self $product) {
FileStorageHelper::removeFile($product, 'picture');
FileStorageHelper::removeFile($product, 'banner');
FileStorageHelper::removeFile($product, 'packaging');
+ self::resetCache();
});
}
@@ -189,6 +195,27 @@ class Product extends Model implements SeoInterface
);
}
+ /**
+ * Reset all cache elements related to this model.
+ * @return void
+ */
+ private static function resetCache()
+ {
+ Cache::forget('publishedDiscoveredProducts');
+ self::getPublishedDiscovered();
+ }
+
+ /**
+ * Get all published products with discover === true.
+ * @return \Illuminate\Database\Eloquent\Collection
+ */
+ public static function getPublishedDiscovered(): \Illuminate\Database\Eloquent\Collection
+ {
+ return Cache::rememberForever('publishedDiscoveredProducts', function () {
+ return self::query()->where('published', true)->where('discover', true)->get();
+ });
+ }
+
// * RELATIONSHIPS
/**
diff --git a/app/Models/Profession.php b/app/Models/Profession.php
index 01141d68..93b07334 100644
--- a/app/Models/Profession.php
+++ b/app/Models/Profession.php
@@ -6,6 +6,7 @@ use App\Lib\Helpers\FileStorageHelper;
use App\Traits\Models\ActivityLog;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\Facades\Cache;
/**
* @property string $title Profession title.
@@ -58,14 +59,42 @@ class Profession extends Model
static::creating(function (self $profession) {
$profession->picture = FileStorageHelper::storeFile($profession, $profession->picture, true);
});
+ static::created(function (self $profession) {
+ self::resetCache();
+ });
static::updating(function (self $profession) {
$profession->picture = FileStorageHelper::storeFile($profession, $profession->picture, true);
});
static::updated(function (self $profession) {
FileStorageHelper::removeOldFile($profession, 'picture');
+ self::resetCache();
});
static::deleted(function (self $profession) {
FileStorageHelper::removeFile($profession, 'picture');
+ self::resetCache();
+ });
+ }
+
+ // * METHODS
+
+ /**
+ * Reset all cache elements related to this model.
+ * @return void
+ */
+ private static function resetCache()
+ {
+ Cache::forget('5publishedProfessions');
+ self::get5Published();
+ }
+
+ /**
+ * Get 5 published professions.
+ * @return \Illuminate\Database\Eloquent\Collection
+ */
+ public static function get5Published(): \Illuminate\Database\Eloquent\Collection
+ {
+ return Cache::rememberForever('5publishedProfessions', function () {
+ return self::query()->where('published', true)->take(5)->get();
});
}
}
diff --git a/app/Models/Range.php b/app/Models/Range.php
index b8bd0248..925fd97c 100644
--- a/app/Models/Range.php
+++ b/app/Models/Range.php
@@ -8,6 +8,7 @@ use App\Lib\Helpers\ToolboxHelper;
use App\Traits\Models\ActivityLog;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;
/**
@@ -84,6 +85,9 @@ class Range extends Model
self::setOrder($model);
self::manageFields($model);
});
+ static::created(function (self $model) {
+ self::resetCache();
+ });
static::updating(function (self $model) {
self::assertLabelIsUnique($model->label, $model->getKey());
self::manageFields($model);
@@ -92,6 +96,7 @@ class Range extends Model
FileStorageHelper::removeOldFile($model, 'banner');
FileStorageHelper::removeOldFile($model, 'banner_ambiance');
FileStorageHelper::removeOldFile($model, 'picture');
+ self::resetCache();
});
static::deleting(function (self $model) {
/** @var \Illuminate\Database\Eloquent\Collection $subranges */
@@ -106,6 +111,7 @@ class Range extends Model
FileStorageHelper::removeFile($model, 'banner');
FileStorageHelper::removeFile($model, 'banner_ambiance');
FileStorageHelper::removeFile($model, 'picture');
+ self::resetCache();
});
}
@@ -151,6 +157,57 @@ class Range extends Model
$model->order = \intval(self::query()->max('order')) + 1;
}
+ /**
+ * Reset all cache elements related to this model.
+ * @return void
+ */
+ private static function resetCache()
+ {
+ Cache::forget('publishedRangesOrderedByOrder');
+ self::getPublishedOrdered();
+ Cache::forget('publishedRangesOrderedBySlug');
+ self::getPublishedOrderedBySlug();
+ Cache::forget('publishedRangesOrderedByOrderWithSubranges');
+ self::getPublishedOrderedWithSubranges();
+ }
+
+ /**
+ * Get all published Ranges ordered by order.
+ * @return \Illuminate\Database\Eloquent\Collection
+ */
+ public static function getPublishedOrdered(): \Illuminate\Database\Eloquent\Collection
+ {
+ return Cache::rememberForever('publishedRangesOrderedByOrder', function () {
+ return self::query()->where('published', true)->orderBy('order')->get();
+ });
+ }
+
+ /**
+ * Get all published Ranges ordered by slug.
+ * @return \Illuminate\Database\Eloquent\Collection
+ */
+ public static function getPublishedOrderedBySlug(): \Illuminate\Database\Eloquent\Collection
+ {
+ return Cache::rememberForever('publishedRangesOrderedBySlug', function () {
+ return self::query()->where('published', true)->orderBy('slug')->get();
+ });
+ }
+
+ /**
+ * Get all published Ranges ordered by order with subranges.
+ * @return \Illuminate\Database\Eloquent\Collection
+ */
+ public static function getPublishedOrderedWithSubranges(): \Illuminate\Database\Eloquent\Collection
+ {
+ return Cache::rememberForever('publishedRangesOrderedByOrderWithSubranges', function () {
+ return self::query()
+ ->where('published', true)
+ ->with('subranges')
+ ->orderBy('order')
+ ->get();
+ });
+ }
+
// * RELATIONSHIPS
/**
diff --git a/app/Models/Recipe.php b/app/Models/Recipe.php
index 92bfa089..d4a1b820 100644
--- a/app/Models/Recipe.php
+++ b/app/Models/Recipe.php
@@ -8,6 +8,7 @@ use App\Lib\Helpers\ToolboxHelper;
use App\Traits\Models\ActivityLog;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;
use Uwil\Seo\Laravel\Interfaces\SeoInterface;
use Uwil\Seo\Laravel\Traits\SeoTrait;
@@ -93,6 +94,9 @@ class Recipe extends Model implements SeoInterface
self::setHighlightValue($model);
self::manageFields($model);
});
+ static::created(function (self $model) {
+ self::resetCache();
+ });
static::updating(function (self $model) {
self::assertTitleIsUnique($model->title, $model->getKey());
self::setHighlightValue($model);
@@ -100,9 +104,11 @@ class Recipe extends Model implements SeoInterface
});
static::updated(function (self $model) {
FileStorageHelper::removeOldFile($model, 'picture');
+ self::resetCache();
});
static::deleted(function (self $model) {
FileStorageHelper::removeFile($model, 'picture');
+ self::resetCache();
});
}
@@ -187,6 +193,45 @@ class Recipe extends Model implements SeoInterface
);
}
+ /**
+ * Reset all cache elements related to this model.
+ * @return void
+ */
+ private static function resetCache()
+ {
+ Cache::forget('publishedFirstHighlightedRecipe');
+ self::getFirstHighlighted();
+ Cache::forget('9publishedRecipesWithProducts');
+ self::get9PublishedWithProducts();
+ }
+
+ /**
+ * Get first published and highlighted recipe.
+ * @return \Illuminate\Database\Eloquent\Collection
+ */
+ public static function getFirstHighlighted(): \Illuminate\Database\Eloquent\Collection
+ {
+ return Cache::rememberForever('publishedFirstHighlightedRecipe', function () {
+ return self::query()->where('published', true)->where('highlight', true)->first();
+ });
+ }
+
+ /**
+ * Get 9 published recipes with products relations.
+ * @return \Illuminate\Database\Eloquent\Collection
+ */
+ public static function get9PublishedWithProducts(): \Illuminate\Database\Eloquent\Collection
+ {
+ return Cache::rememberForever('9publishedRecipesWithProducts', function () {
+ return self::query()->where('published', true)->with([
+ 'products',
+ 'products.meat',
+ 'products.submeat',
+ 'consumptionMoment'
+ ])->limit(9)->get();
+ });
+ }
+
// * RELATIONSHIPS
/**
diff --git a/app/Models/StaticPage.php b/app/Models/StaticPage.php
index 3872ceb7..be936313 100644
--- a/app/Models/StaticPage.php
+++ b/app/Models/StaticPage.php
@@ -9,6 +9,7 @@ use App\Traits\Models\ActivityLog;
use App\Traits\Models\MiniCrudModel;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;
/**
@@ -79,6 +80,8 @@ class StaticPage extends Model
});
static::updated(function (self $model) {
FileStorageHelper::removeOldFile($model, 'picture');
+
+ self::resetCache($model->type);
});
static::deleted(function () {
throw new \RuntimeException('Deleting a page is not authorized');
@@ -129,4 +132,44 @@ class StaticPage extends Model
ToolboxHelper::assertFieldIsUnique($table, 'slug', Str::slug($seo_title), $id);
}
}
+
+ /**
+ * Reset all cache elements related to this model.
+ * @return void
+ */
+ private static function resetCache(StaticPageType $type)
+ {
+ Cache::forget(sprintf('%sStaticPage', $type->name));
+ self::getCachedStaticPage($type);
+
+ // Breeding pages.
+ Cache::forget('breedingStaticPages');
+ self::getCachedBreedingStaticPages();
+ }
+
+ /**
+ * Get cached static page associated to a given type.
+ * @param \App\Enums\StaticPageType $type
+ * @return \App\Models\StaticPage
+ */
+ public static function getCachedStaticPage(StaticPageType $type)
+ {
+ return Cache::rememberForever(
+ sprintf('%sStaticPage', $type->name),
+ fn() => self::query()->where('type', $type)->first()
+ );
+ }
+
+ /**
+ * Get cached static pages associated to all breeding types.
+ * @param \App\Enums\StaticPageType $type
+ * @return \Illuminate\Database\Eloquent\Collection
+ */
+ public static function getCachedBreedingStaticPages()
+ {
+ return Cache::rememberForever(
+ 'breedingStaticPages',
+ fn() => self::query()->whereIn('type', StaticPageType::getBreedingPages())->get()
+ );
+ }
}
diff --git a/app/Models/Submeat.php b/app/Models/Submeat.php
index 250871ac..77739d95 100644
--- a/app/Models/Submeat.php
+++ b/app/Models/Submeat.php
@@ -7,6 +7,7 @@ use App\Lib\Helpers\ToolboxHelper;
use App\Traits\Models\ActivityLog;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;
/**
@@ -70,15 +71,20 @@ class Submeat extends Model
self::setOrder($model);
self::manageFields($model);
});
+ static::created(function (self $model) {
+ self::resetCache();
+ });
static::updating(function (self $model) {
self::assertLabelIsUnique($model->label, $model->getKey());
self::manageFields($model);
});
static::updated(function (self $model) {
FileStorageHelper::removeOldFile($model, 'picture');
+ self::resetCache();
});
static::deleted(function (self $model) {
FileStorageHelper::removeFile($model, 'picture');
+ self::resetCache();
});
}
@@ -122,6 +128,27 @@ class Submeat extends Model
$model->order = \intval(self::query()->max('order')) + 1;
}
+ /**
+ * Reset all cache elements related to this model.
+ * @return void
+ */
+ private static function resetCache()
+ {
+ Cache::forget('publishedSubmeatsOrderedByOrder');
+ self::getPublishedOrdered();
+ }
+
+ /**
+ * Get all published Subeats ordered by order.
+ * @return \Illuminate\Database\Eloquent\Collection
+ */
+ public static function getPublishedOrdered(): \Illuminate\Database\Eloquent\Collection
+ {
+ return Cache::rememberForever('publishedSubmeatsOrderedByOrder', function () {
+ return self::query()->where('published', true)->orderBy('order')->get();
+ });
+ }
+
// * RELATIONSHIPS
/**
diff --git a/app/Models/Subrange.php b/app/Models/Subrange.php
index 126ba26a..6fcc6c10 100644
--- a/app/Models/Subrange.php
+++ b/app/Models/Subrange.php
@@ -7,6 +7,7 @@ use App\Lib\Helpers\ToolboxHelper;
use App\Traits\Models\ActivityLog;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;
/**
@@ -69,15 +70,20 @@ class Subrange extends Model
self::setOrder($model);
self::manageFields($model);
});
+ static::created(function (self $model) {
+ self::resetCache();
+ });
static::updating(function (self $model) {
self::assertLabelIsUnique($model->label, $model->getKey());
self::manageFields($model);
});
static::updated(function (self $model) {
FileStorageHelper::removeOldFile($model, 'picture');
+ self::resetCache();
});
static::deleted(function (self $model) {
FileStorageHelper::removeFile($model, 'picture');
+ self::resetCache();
});
}
@@ -121,6 +127,27 @@ class Subrange extends Model
$model->order = \intval(self::query()->max('order')) + 1;
}
+ /**
+ * Reset all cache elements related to this model.
+ * @return void
+ */
+ private static function resetCache()
+ {
+ Cache::forget('publishedSubrangesOrderedByOrder');
+ self::getPublishedOrdered();
+ }
+
+ /**
+ * Get all published Subranges ordered by order.
+ * @return \Illuminate\Database\Eloquent\Collection
+ */
+ public static function getPublishedOrdered(): \Illuminate\Database\Eloquent\Collection
+ {
+ return Cache::rememberForever('publishedSubrangesOrderedByOrder', function () {
+ return self::query()->where('published', true)->orderBy('order')->get();
+ });
+ }
+
// * RELATIONSHIPS
/**
diff --git a/app/Models/Testimonial.php b/app/Models/Testimonial.php
index 5f0f36bf..dac6c3a0 100644
--- a/app/Models/Testimonial.php
+++ b/app/Models/Testimonial.php
@@ -6,6 +6,7 @@ use App\Lib\Helpers\FileStorageHelper;
use App\Traits\Models\ActivityLog;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\Rule;
@@ -66,14 +67,19 @@ class Testimonial extends Model
self::setOrder($model);
self::manageFields($model);
});
+ static::created(function (self $model) {
+ self::resetCache();
+ });
static::updating(function (self $model) {
self::manageFields($model);
});
static::updated(function (self $model) {
FileStorageHelper::removeOldFile($model, 'picture');
+ self::resetCache();
});
static::deleted(function (self $model) {
FileStorageHelper::removeFile($model, 'picture');
+ self::resetCache();
});
}
@@ -125,4 +131,25 @@ class Testimonial extends Model
])
])->validate();
}
+
+ /**
+ * Reset all cache elements related to this model.
+ * @return void
+ */
+ private static function resetCache()
+ {
+ Cache::forget('publishedTestimonialsOrderedByOrder');
+ self::getPublishedOrdered();
+ }
+
+ /**
+ * Get all published Testimonials ordered by order.
+ * @return \Illuminate\Database\Eloquent\Collection
+ */
+ public static function getPublishedOrdered(): \Illuminate\Database\Eloquent\Collection
+ {
+ return Cache::rememberForever('publishedTestimonialsOrderedByOrder', function () {
+ return self::query()->where('published', true)->orderBy('order')->get();
+ });
+ }
}
diff --git a/app/Models/Video.php b/app/Models/Video.php
index 9098977f..5c188840 100644
--- a/app/Models/Video.php
+++ b/app/Models/Video.php
@@ -5,6 +5,7 @@ namespace App\Models;
use App\Traits\Models\ActivityLog;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\Facades\Cache;
/**
* @property string $title Video title.
@@ -57,6 +58,15 @@ class Video extends Model
static::creating(function (self $video) {
self::setOrder($video);
});
+ static::created(function (self $video) {
+ self::resetCache();
+ });
+ static::updated(function (self $video) {
+ self::resetCache();
+ });
+ static::deleted(function (self $video) {
+ self::resetCache();
+ });
}
// * METHODS
@@ -72,6 +82,51 @@ class Video extends Model
$model->order = \intval(self::query()->max('order')) + 1;
}
+ /**
+ * Reset all cache elements related to this model.
+ * @return void
+ */
+ private static function resetCache()
+ {
+ Cache::forget('9publishedHomeVideosOrderedByOrderWithProducts');
+ self::get9PublishedHomeVideosOrderedWithProducts();
+ Cache::forget('6publishedVideosOrderedByOrderWithProducts');
+ self::get6PublishedVideosOrderedWithProducts();
+ }
+
+ /**
+ * Get 9 published Videos to display in homepage ordered by order with products relations.
+ * @return \Illuminate\Database\Eloquent\Collection
+ */
+ public static function get9PublishedHomeVideosOrderedWithProducts(): \Illuminate\Database\Eloquent\Collection
+ {
+ return Cache::rememberForever('9publishedHomeVideosOrderedByOrderWithProducts', function () {
+ return self::query()
+ ->where('published', true)
+ ->where('is_on_homepage', true)
+ ->orderBy('order')
+ ->with('product')
+ ->limit(9)
+ ->get();
+ });
+ }
+
+ /**
+ * Get 9 published Videos to display in homepage ordered by order with products relations.
+ * @return \Illuminate\Database\Eloquent\Collection
+ */
+ public static function get6PublishedVideosOrderedWithProducts(): \Illuminate\Database\Eloquent\Collection
+ {
+ return Cache::rememberForever('6publishedVideosOrderedByOrderWithProducts', function () {
+ return self::query()
+ ->where('published', true)
+ ->orderBy('order')
+ ->with('product')
+ ->take(6)
+ ->get();
+ });
+ }
+
// * RELATIONSHIPS
/**
diff --git a/app/Providers/ViewServiceProvider.php b/app/Providers/ViewServiceProvider.php
index 82dfaa78..b6e1497e 100644
--- a/app/Providers/ViewServiceProvider.php
+++ b/app/Providers/ViewServiceProvider.php
@@ -81,7 +81,7 @@ class ViewServiceProvider extends ServiceProvider
if (!$mainMenu) {
throw new \RuntimeException('Missing setting ' . SettingsType::mainMenu->label());
}
- return StaticPage::query()->whereIn('type', StaticPageType::getBreedingPages())->get();
+ return StaticPage::getCachedBreedingStaticPages();
})());
// * Inject configuration model
@@ -91,53 +91,34 @@ class ViewServiceProvider extends ServiceProvider
['name' => 'breederMapComponentSettingModel', 'enum' => SettingsType::breederMapComponent],
])->map(function ($array) {
View::share($array['name'], (function () use ($array) {
- return GeneralSetting::query()->where('type', $array['enum'])->first() ?: null;
+ return GeneralSetting::getCachedGeneralSetting($array['enum']) ?: null;
})());
});
// * Inject some data for the bo menu.
collect([
- ['name' => 'customerModelsCount', 'value' => count(Customer::query()->get())],
+ ['name' => 'customerModelsCount', 'value' => Customer::query()->count()],
['name' => 'firstMeat', 'value' => Meat::query()->first()],
['name' => 'firstRange', 'value' => Range::query()->first()],
- ['name' => 'mainMenuRangeModels', 'value' => Range::query()->orderBy('order', 'ASC')
- ->where('published', true)->get()],
- ['name' => 'mainMenuMeatModels', 'value' => Meat::query()->orderBy('order', 'ASC')
- ->where('published', true)->get()],
- ['name' => 'homeStaticPageModel', 'value' => StaticPage::query()
- ->where('type', StaticPageType::home)->first()],
- ['name' => 'storyStaticPageModel', 'value' => StaticPage::query()
- ->where('type', StaticPageType::story)->first()],
- ['name' => 'recruitmentStaticPageModel', 'value' => StaticPage::query()
- ->where('type', StaticPageType::recruitment)->first()],
- ['name' => 'sagaStaticPageModel', 'value' => StaticPage::query()
- ->where('type', StaticPageType::saga)->first()],
- ['name' => 'recipesStaticPageModel', 'value' => StaticPage::query()
- ->where('type', StaticPageType::recipes)->first()],
- ['name' => 'recipeStaticPageModel', 'value' => StaticPage::query()
- ->where('type', StaticPageType::recipe)->first()],
- ['name' => 'productsStaticPageModel', 'value' => StaticPage::query()
- ->where('type', StaticPageType::products)->first()],
- ['name' => 'legalsStaticPageModel', 'value' => StaticPage::query()
- ->where('type', StaticPageType::legals)->first()],
- ['name' => 'confidentialityStaticPageModel', 'value' => StaticPage::query()
- ->where('type', StaticPageType::confidentiality)->first()],
- ['name' => 'sellingStaticPageModel', 'value' => StaticPage::query()
- ->where('type', StaticPageType::selling)->first()],
- ['name' => 'accessibilityStaticPageModel', 'value' => StaticPage::query()
- ->where('type', StaticPageType::accessibility)->first()],
- ['name' => 'productStaticPageModel', 'value' => StaticPage::query()
- ->where('type', StaticPageType::product)->first()],
- ['name' => 'breedingPoultryStaticPageModel', 'value' => StaticPage::query()
- ->where('type', StaticPageType::breedingPoultry)->first()],
- ['name' => 'breedingJobStaticPageModel', 'value' => StaticPage::query()
- ->where('type', StaticPageType::breedingJob)->first()],
- ['name' => 'breedingFoodStaticPageModel', 'value' => StaticPage::query()
- ->where('type', StaticPageType::breedingFood)->first()],
- ['name' => 'breedingHealthStaticPageModel', 'value' => StaticPage::query()
- ->where('type', StaticPageType::breedingHealth)->first()],
- ['name' => 'newsStaticPageModel', 'value' => StaticPage::query()
- ->where('type', StaticPageType::news)->first()],
+ ['name' => 'mainMenuRangeModels', 'value' => Range::getPublishedOrdered()],
+ ['name' => 'mainMenuMeatModels', 'value' => Meat::getPublishedOrdered()],
+ ['name' => 'homeStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::home)],
+ ['name' => 'storyStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::story)],
+ ['name' => 'recruitmentStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::recruitment)],
+ ['name' => 'sagaStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::saga)],
+ ['name' => 'recipesStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::recipes)],
+ ['name' => 'recipeStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::recipe)],
+ ['name' => 'productsStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::products)],
+ ['name' => 'legalsStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::legals)],
+ ['name' => 'confidentialityStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::confidentiality)],
+ ['name' => 'sellingStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::selling)],
+ ['name' => 'accessibilityStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::accessibility)],
+ ['name' => 'productStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::product)],
+ ['name' => 'breedingPoultryStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::breedingPoultry)],
+ ['name' => 'breedingJobStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::breedingJob)],
+ ['name' => 'breedingFoodStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::breedingFood)],
+ ['name' => 'breedingHealthStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::breedingHealth)],
+ ['name' => 'newsStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::news)],
])->map(function ($array) {
View::share($array['name'], (function () use ($array) {
return $array['value'] ?: null;
diff --git a/app/View/Components/Fo/BreedingsLinksCards.php b/app/View/Components/Fo/Breeding/BreedingsLinksCards.php
similarity index 89%
rename from app/View/Components/Fo/BreedingsLinksCards.php
rename to app/View/Components/Fo/Breeding/BreedingsLinksCards.php
index 233ec530..dd58c672 100644
--- a/app/View/Components/Fo/BreedingsLinksCards.php
+++ b/app/View/Components/Fo/Breeding/BreedingsLinksCards.php
@@ -1,6 +1,6 @@
staticPageModel = StaticPage::getCachedStaticPage(StaticPageType::story);
+ $this->historicalMilestoneModels = HistoricalMilestone::getPublishedOrderedByYear();
+ }
+
+ /**
+ * Get the view / contents that represent the component.
+ */
+ public function render(): View|Closure|string
+ {
+ return view('components.fo.story.historical-milestone-component', [
+ 'staticPageModel' => $this->staticPageModel,
+ 'historicalMilestoneModels' => $this->historicalMilestoneModels
+ ]);
+ }
+}
diff --git a/app/View/Components/Fo/Story/WhoWeAre.php b/app/View/Components/Fo/Story/WhoWeAre.php
new file mode 100644
index 00000000..d4a149ab
--- /dev/null
+++ b/app/View/Components/Fo/Story/WhoWeAre.php
@@ -0,0 +1,35 @@
+staticPageModel = StaticPage::getCachedStaticPage(StaticPageType::story);
+ $this->displayButton = $displayButton;
+ }
+
+ /**
+ * Get the view / contents that represent the component.
+ */
+ public function render(): View|Closure|string
+ {
+ // Passe la donnée à la vue
+ return view('components.fo.story.who-we-are', [
+ 'staticPageModel' => $this->staticPageModel,
+ ]);
+ }
+}
diff --git a/resources/assets/images/page-des-40-ans/section3/pack-lg.png b/resources/assets/images/page-des-40-ans/section3/pack-lg.png
deleted file mode 100644
index 6be3b2a6..00000000
Binary files a/resources/assets/images/page-des-40-ans/section3/pack-lg.png and /dev/null differ
diff --git a/resources/assets/images/page-des-40-ans/section3/products/1.png b/resources/assets/images/page-des-40-ans/section3/products/1.png
new file mode 100644
index 00000000..c094b420
Binary files /dev/null and b/resources/assets/images/page-des-40-ans/section3/products/1.png differ
diff --git a/resources/assets/images/page-des-40-ans/section3/products/2.png b/resources/assets/images/page-des-40-ans/section3/products/2.png
new file mode 100644
index 00000000..8fdc60a3
Binary files /dev/null and b/resources/assets/images/page-des-40-ans/section3/products/2.png differ
diff --git a/resources/assets/images/page-des-40-ans/section3/products/3.png b/resources/assets/images/page-des-40-ans/section3/products/3.png
new file mode 100644
index 00000000..f24e75c7
Binary files /dev/null and b/resources/assets/images/page-des-40-ans/section3/products/3.png differ
diff --git a/resources/assets/images/page-des-40-ans/section3/products/4.png b/resources/assets/images/page-des-40-ans/section3/products/4.png
new file mode 100644
index 00000000..21b2e9e2
Binary files /dev/null and b/resources/assets/images/page-des-40-ans/section3/products/4.png differ
diff --git a/resources/assets/images/page-des-40-ans/section3/products/5.png b/resources/assets/images/page-des-40-ans/section3/products/5.png
new file mode 100644
index 00000000..aacf1b3a
Binary files /dev/null and b/resources/assets/images/page-des-40-ans/section3/products/5.png differ
diff --git a/resources/assets/images/page-des-40-ans/section3/temp-fort-1.svg b/resources/assets/images/page-des-40-ans/section3/temp-fort-1.svg
deleted file mode 100644
index 8dda4f41..00000000
--- a/resources/assets/images/page-des-40-ans/section3/temp-fort-1.svg
+++ /dev/null
@@ -1,9 +0,0 @@
-
diff --git a/resources/assets/images/page-des-40-ans/section3/texte-animation-anniversaire.svg b/resources/assets/images/page-des-40-ans/section3/texte-animation-anniversaire.svg
deleted file mode 100644
index 9a5cc044..00000000
--- a/resources/assets/images/page-des-40-ans/section3/texte-animation-anniversaire.svg
+++ /dev/null
@@ -1,25 +0,0 @@
-
diff --git a/resources/assets/images/page-des-40-ans/section5/40ans-cocotte.jpg b/resources/assets/images/page-des-40-ans/section5/40ans-cocotte.jpg
new file mode 100644
index 00000000..9370d558
Binary files /dev/null and b/resources/assets/images/page-des-40-ans/section5/40ans-cocotte.jpg differ
diff --git a/resources/assets/images/page-des-40-ans/section5/40ans-guess.jpg b/resources/assets/images/page-des-40-ans/section5/40ans-guess.jpg
new file mode 100644
index 00000000..217127c9
Binary files /dev/null and b/resources/assets/images/page-des-40-ans/section5/40ans-guess.jpg differ
diff --git a/resources/assets/images/page-des-40-ans/section5/40ans-regale.jpg b/resources/assets/images/page-des-40-ans/section5/40ans-regale.jpg
new file mode 100644
index 00000000..35e24ad7
Binary files /dev/null and b/resources/assets/images/page-des-40-ans/section5/40ans-regale.jpg differ
diff --git a/resources/assets/images/page-des-40-ans/section5/image-assiette-cordon.png b/resources/assets/images/page-des-40-ans/section5/image-assiette-cordon.png
deleted file mode 100644
index 3aa2bd61..00000000
Binary files a/resources/assets/images/page-des-40-ans/section5/image-assiette-cordon.png and /dev/null differ
diff --git a/resources/assets/images/page-des-40-ans/section5/image-cordon-bleu.png b/resources/assets/images/page-des-40-ans/section5/image-cordon-bleu.png
deleted file mode 100644
index ce6c07a9..00000000
Binary files a/resources/assets/images/page-des-40-ans/section5/image-cordon-bleu.png and /dev/null differ
diff --git a/resources/assets/images/page-des-40-ans/section5/image-crousti-gourmand.png b/resources/assets/images/page-des-40-ans/section5/image-crousti-gourmand.png
deleted file mode 100644
index bf619771..00000000
Binary files a/resources/assets/images/page-des-40-ans/section5/image-crousti-gourmand.png and /dev/null differ
diff --git a/resources/lang/de.json b/resources/lang/de.json
new file mode 100644
index 00000000..1ff8223a
--- /dev/null
+++ b/resources/lang/de.json
@@ -0,0 +1,41 @@
+{
+ "homepage": "startseite",
+ "40years.more-gifts-to-win": "Noch mehr Geschenke zu gewinnen",
+ "40years.collect-points": "Sammeln Sie Punkte und wählen Sie Ihre Geschenke in unserem Shop aus!",
+ "40years.1euro-spent": "1€ ausgegeben",
+ "40years.1point-collected": "1 Punkt gesammelt",
+ "40years.2-levels": "2 Stufen",
+ "40years.many-gifts": "zahlreiche Geschenke",
+ "40years.discover-our-store": "Entdecken Sie unseren Shop",
+ "40years.find-the-golden-magnets": "Finden Sie die goldenen Magneten",
+ "40years.win-a-surprise": "und gewinnen Sie eine Überraschung!",
+ "40years.hide-golden-magnet": "Zu seinem 40-jährigen Jubiläum hat Le Gaulois 94 goldene Magneten",
+ "40years.in-his-panes-cases": "in seinen Schachteln von panierten Produkten versteckt!",
+ "40years.i-discover": "Ich entdecke",
+ "40years.a-golden-magnet": "einen goldenen Magnet",
+ "40years.i-win": "Ich gewinne",
+ "40years.a-collector-map": "eine Sammlerkarte von Frankreich, die von einem jungen französischen Künstler entworfen wurde, und eine komplette Sammlung goldener Magnete!",
+ "40years.happy-searching": "Viel Spaß beim Suchen!",
+ "40years.play-with-us": "Spielen Sie mit uns!",
+ "40years.more-gifts": "Noch mehr Geschenke!",
+ "40years.banner": "Seit 40 Jahren verpflichtet sich Le Gaulois, Produkte anzubieten, die zu 100% aus Frankreich stammen mit Geflügel, das in unserem Land geboren, aufgezogen und verarbeitet wurde.
40 Jahre Geselligkeit und Freude \"à la française\", die wir mit Ihnen teilen möchten!
Entdecken Sie in diesem festlichen Jahr unsere Spiele und Überraschungen.",
+ "40years.game-title": "40 Jahre!",
+ "40years.game-subtitle": "Das Jubiläum aller Gaulois",
+ "40years.visit-your-store": "Finden Sie unsere Produkte in den Geschäften und haben Sie die Chance, tolle Geschenke zu gewinnen!",
+ "40years.dream-stays": "Traumaufenthalte",
+ "40years.dream-stays-subtitle": "im Wert von 4.000 €",
+ "40years.camera": "Kameras",
+ "40years.discount-title": "Tausende",
+ "40years.discount-subtitle": "von Rabattgutscheinen",
+ "40years.how-to": "Wie wird",
+ "40years.play": "gespielt?",
+ "40years.bearing-products-top": "Zahlreiche Produkte,",
+ "40years.bearing-products-bottom": "die Angebote tragen",
+ "40years.to-participate": "Um teilzunehmen, kaufen Sie eines unserer Produkte, das den Aufkleber trägt.",
+ "40years.see-you-in-store": "Wir sehen uns im Geschäft!",
+ "40years.i-participate": "Ich nehme am Spiel teil",
+ "40years.breadcrumb": "40 Jahre! Das Jubiläum aller Gaulois",
+ "40years.animations": "Animationen in den Geschäften!",
+ "40years.highlight": "Highlights",
+ "40years.highlight-date": "vom 2. September bis zum 30. November"
+}
diff --git a/resources/lang/en.json b/resources/lang/en.json
index d208ff28..957e0d0e 100644
--- a/resources/lang/en.json
+++ b/resources/lang/en.json
@@ -50,5 +50,44 @@
"Verify Your Email Address": "Verify Your Email Address",
"Whoops!": "Whoops!",
"You are logged in!": "You are logged in!",
- "You are receiving this email because we received a password reset request for your account.": "You are receiving this email because we received a password reset request for your account."
-}
\ No newline at end of file
+ "You are receiving this email because we received a password reset request for your account.": "You are receiving this email because we received a password reset request for your account.",
+ "homepage": "homepage",
+ "40years.more-gifts-to-win": "Even more gifts to win",
+ "40years.collect-points": "Collect points and choose your gifts in our store!",
+ "40years.1euro-spent": "1€ spent",
+ "40years.1point-collected": "1 point collected",
+ "40years.2-levels": "2 levels",
+ "40years.many-gifts": "Many gifts",
+ "40years.discover-our-store": "Discover our store",
+ "40years.find-the-golden-magnets": "Find the golden magnets",
+ "40years.win-a-surprise": "and win a surprise!",
+ "40years.hide-golden-magnet": "For his 40th birthday, Le Gaulois hid 94 golden magnets",
+ "40years.in-his-panes-cases": "in his Panés cases",
+ "40years.i-discover": "I discovered",
+ "40years.a-golden-magnet": "a golden magnet",
+ "40years.i-win": "I won",
+ "40years.a-collector-map": "a 40th anniversary collector's card of France created by a young French artist and a complete collection of golden magnets!",
+ "40years.happy-searching": "Happy searching everyone!",
+ "40years.play-with-us": "Play with us!",
+ "40years.more-gifts": "Even more gifts!",
+ "40years.banner": "For 40 years, Le Gaulois has been committed to offering products 100% of French origin with poultry born, raised and prepared in our territory.
40 years of French conviviality to share with you!
During this festive year, discover our games and our surprises.",
+ "40years.game-title": "40 years!",
+ "40years.game-subtitle": "The birthday of all our Gaulois",
+ "40years.visit-your-store": "Visit your local store for a chance to win exceptional gifts!",
+ "40years.dream-stays": "Dream stays",
+ "40years.dream-stays-subtitle": "worth €4,000",
+ "40years.camera": "Cameras",
+ "40years.discount-title": "Thousands",
+ "40years.discount-subtitle": "of discount vouchers",
+ "40years.how-to": "How to",
+ "40years.play": "play?",
+ "40years.bearing-products-top": "Many",
+ "40years.bearing-products-bottom": "bearing products",
+ "40years.to-participate": "To participate, purchase one of our products bearing the sticker.",
+ "40years.see-you-in-store": "See you in store!",
+ "40years.i-participate": "I participate",
+ "40years.breadcrumb": "40 years! The birthday of all our Gaulois",
+ "40years.animations": "In-store events!",
+ "40years.highlight": "Highlight",
+ "40years.highlight-date": "from September 2 to November 30"
+}
diff --git a/resources/lang/fr.json b/resources/lang/fr.json
index 083064b8..db14f0f0 100644
--- a/resources/lang/fr.json
+++ b/resources/lang/fr.json
@@ -50,5 +50,44 @@
"Verify Your Email Address": "Vérifiez votre adresse e-mail",
"Whoops!": "Oups !",
"You are logged in!": "Vous êtes connecté·e !",
- "You are receiving this email because we received a password reset request for your account.": "Vous recevez cet e-mail car nous avons reçu une demande de réinitialisation de mot de passe pour votre compte."
+ "You are receiving this email because we received a password reset request for your account.": "Vous recevez cet e-mail car nous avons reçu une demande de réinitialisation de mot de passe pour votre compte.",
+ "homepage": "accueil",
+ "40years.more-gifts-to-win": "Encore + de cadeaux à gagner",
+ "40years.collect-points": "Collectez des points et choisissez vos cadeaux dans notre boutique !",
+ "40years.1euro-spent": "1€ dépensé",
+ "40years.1point-collected": "1 point collecté",
+ "40years.2-levels": "2 paliers",
+ "40years.many-gifts": "de nombreux cadeaux",
+ "40years.discover-our-store": "Découvrez notre boutique",
+ "40years.find-the-golden-magnets": "Trouvez les magnets dorés",
+ "40years.win-a-surprise": "et remportez une surprise !",
+ "40years.hide-golden-magnet": "Pour ses 40 ans, Le Gaulois a caché 94 magnets dorés",
+ "40years.in-his-panes-cases": "dans ses étuis de Panés",
+ "40years.i-discover": "Je découvre",
+ "40years.a-golden-magnet": "un Magnet doré",
+ "40years.i-win": "Je gagne",
+ "40years.a-collector-map": "une carte de France collector 40 ans créée par un jeune artiste français et une collection complète de magnets dorés !",
+ "40years.happy-searching": "Bonne recherche à tous !",
+ "40years.play-with-us": "Jouez avec nous !",
+ "40years.more-gifts": "Encore + de cadeaux !",
+ "40years.banner": "Depuis 40 ans, Le Gaulois s'engage à proposer des produits 100 % origine France avec des volailles nées, élevées et préparées sur notre territoire.
40 ans de convivialité et de plaisir à la française, à partager avec vous !
Pendant cette année festive, découvrez nos jeux et nos surprises.",
+ "40years.game-title": "Le jeu des 40 ans",
+ "40years.game-subtitle": "100% gagnant",
+ "40years.visit-your-store": "Rendez-vous en magasin, et tentez de remporter des cadeaux exceptionnels !",
+ "40years.dream-stays": "Séjours de rêve",
+ "40years.dream-stays-subtitle": "d'une valeur de 4000€",
+ "40years.camera": "Appareils photos",
+ "40years.discount-title": "Des
milliers",
+ "40years.discount-subtitle": "de bons de réduction",
+ "40years.how-to": "Comment",
+ "40years.play": "jouer ?",
+ "40years.bearing-products-top": "De nombreux",
+ "40years.bearing-products-bottom": "produits porteurs",
+ "40years.to-participate": "Pour participer, achetez un de nos produits porteurs du sticker.",
+ "40years.see-you-in-store": "Rendez-vous en magasin !",
+ "40years.i-participate": "Je participe",
+ "40years.breadcrumb": "40 ans ! L'anniversaire de tous les Gaulois",
+ "40years.animations": "Des animations en magasin\u00A0!",
+ "40years.highlight": "Temps fort",
+ "40years.highlight-date": "du 2 septembre au 30 novembre"
}
diff --git a/resources/lang/nl.json b/resources/lang/nl.json
new file mode 100644
index 00000000..ac240255
--- /dev/null
+++ b/resources/lang/nl.json
@@ -0,0 +1,41 @@
+{
+ "homepage": "startpagina",
+ "40years.more-gifts-to-win": "Nog meer geschenken te winnen",
+ "40years.collect-points": "Verzamel punten en kies uw geschenk in onze winkel!",
+ "40years.1euro-spent": "1€ besteed",
+ "40years.1point-collected": "1 verzameld punt",
+ "40years.2-levels": "2 niveaus",
+ "40years.many-gifts": "talloze geschenken",
+ "40years.discover-our-store": "Ontdek onze winkel",
+ "40years.find-the-golden-magnets": "Vind de gouden magneten",
+ "40years.win-a-surprise": "en win een verrassing!",
+ "40years.hide-golden-magnet": "Voor zijn 40e verjaardag verborg Le Gaulois 94 gouden magneten",
+ "40years.in-his-panes-cases": "in zijn verpakkingen met gepaneerde producten",
+ "40years.i-discover": "Ik ontdek",
+ "40years.a-golden-magnet": "een gouden magneet",
+ "40years.i-win": "Ik won",
+ "40years.a-collector-map": "een verzamelkaart van Frankrijk collectie 40-jaar, ontworpen door een jonge Franse kunstenaar, en een volledige verzameling gouden magneten!",
+ "40years.happy-searching": "Veel zoekplezier aan allen!",
+ "40years.play-with-us": "Speel met ons!",
+ "40years.more-gifts": "nog meer geschenken!",
+ "40years.banner": "Sinds 40 jaar zet Le Gaulois zich in om producten aan te bieden van 100% Franse origine,gevogelte geboren, gekweekt en bereidt op ons grondgebied.
40 jaar Franse gezelligheid en gebruiksgemak, om met u te delen!
Ontdek tijdens dit feestjaar onze spelen en verrassingen.",
+ "40years.game-title": "40 jaar!",
+ "40years.game-subtitle": "De verjaardag van alle Gaulois",
+ "40years.visit-your-store": "Bezoek de winkel en probeer uitzonderlijke geschenken te winnen!",
+ "40years.dream-stays": "Droomverblijven",
+ "40years.dream-stays-subtitle": "ter waarde van € 4.000",
+ "40years.camera": "Fototoestellen",
+ "40years.discount-title": "Duizenden",
+ "40years.discount-subtitle": "kortingsbonnen",
+ "40years.how-to": "Hoe te",
+ "40years.play": "spelen?",
+ "40years.bearing-products-top": "Veel",
+ "40years.bearing-products-bottom": "deelnemende producten",
+ "40years.to-participate": "Om deel te nemen, koopt u een van onze producten met de sticker.",
+ "40years.see-you-in-store": "Tot ziens in de winkel!",
+ "40years.i-participate": "Ik neem deel",
+ "40years.breadcrumb": "40 jaar! De verjaardag van alle Gaulois",
+ "40years.animations": "Animaties in de winkel!",
+ "40years.highlight": "Hoogtepunt",
+ "40years.highlight-date": "van 2 september tot 30 november"
+}
diff --git a/resources/sass/fo/base/_layout.scss b/resources/sass/fo/base/_layout.scss
index e62daf56..1465bf18 100644
--- a/resources/sass/fo/base/_layout.scss
+++ b/resources/sass/fo/base/_layout.scss
@@ -7,7 +7,7 @@ body {
flex-direction: column;
// * HEADER
- > header {
+ >header {
position: fixed;
z-index: 1020;
top: 0;
@@ -154,7 +154,7 @@ body {
}
}
- .nav-link:hover{
+ .nav-link:hover {
overflow: visible;
&::before {
@@ -180,6 +180,7 @@ body {
#main-nav,
// * Mobile Offcanvas Nav
#offcanvas-main-menu {
+
// * Center vertical menu link
.nav-item {
display: flex;
@@ -200,7 +201,7 @@ body {
}
}
- .nav-link:hover{
+ .nav-link:hover {
overflow: visible;
&::before {
@@ -260,7 +261,7 @@ body {
@include rfs(30rem, min-width);
}
- + label {
+ +label {
height: 2rem;
padding: 0.5rem 0.25rem;
line-height: 1.2;
@@ -272,6 +273,10 @@ body {
#menu-lang-list {
display: none;
+ .dropdown-menu {
+ min-width: fit-content;
+ }
+
@include media-breakpoint-up(lg) {
display: list-item;
}
@@ -279,18 +284,18 @@ body {
}
/** For home page usage */
- > .no-offset {
+ >.no-offset {
margin-top: 0;
}
- > main {
+ >main {
flex-grow: 1;
flex-shrink: 0;
margin-top: $top-menu-offset;
}
// * FOOTER
- > footer {
+ >footer {
position: relative;
flex-grow: 0;
flex-shrink: 1;
@@ -441,8 +446,10 @@ body {
}
}
- > footer, > header {
- .btn-social, .btn-lang {
+ >footer,
+ >header {
+ .btn-social,
+ .btn-lang {
width: 2.3rem;
height: 2.3rem;
padding: 0.1rem;
diff --git a/resources/sass/fo/fo.scss b/resources/sass/fo/fo.scss
index 4ca47c4c..1941a4c0 100644
--- a/resources/sass/fo/fo.scss
+++ b/resources/sass/fo/fo.scss
@@ -31,6 +31,7 @@
@import "./pages/breeding/approaches";
@import "./pages/breeding/article";
@import "./pages/page-des-40-ans";
+@import "./pages/export-40-ans";
@import "./pages/news";
// * PARTIALS
diff --git a/resources/sass/fo/pages/export-40-ans.scss b/resources/sass/fo/pages/export-40-ans.scss
new file mode 100644
index 00000000..e87bfac2
--- /dev/null
+++ b/resources/sass/fo/pages/export-40-ans.scss
@@ -0,0 +1,14 @@
+#export-40-ans {
+ #hero {
+ min-height: 85vh;
+ background-color: #efd;
+
+ .export-hero {
+ &-wrapper {
+ min-height: inherit;
+ }
+
+
+ }
+ }
+}
diff --git a/resources/sass/fo/pages/page-des-40-ans.scss b/resources/sass/fo/pages/page-des-40-ans.scss
index 2ed57a68..87cd2d5f 100644
--- a/resources/sass/fo/pages/page-des-40-ans.scss
+++ b/resources/sass/fo/pages/page-des-40-ans.scss
@@ -5,6 +5,10 @@
overflow-y: visible;
}
+ .breadcrumb-item {
+ color: $color-primary !important;
+ }
+
#section-40-ans {
min-height: 80vh;
overflow-x: hidden;
@@ -258,7 +262,7 @@
transform: scaleX(-100%);
}
- h2 {
+ h1 {
z-index: 1;
padding-top: 35px;
@@ -464,7 +468,7 @@
@include media-breakpoint-up(lg) {
top: 50%;
- left: -10%;
+ left: -5%;
max-width: 211px;
transform: rotate(-3deg);
}
@@ -509,7 +513,7 @@
&-container {
position: absolute;
top: -38%;
- right: -29%;
+ right: -5%;
display: none;
max-width: 263px;
transform: rotate(5deg);
@@ -535,9 +539,13 @@
@include media-breakpoint-up(md) {
z-index: 1;
- right: -18%;
+ right: -5%;
transform: translateX(0%);
}
+
+ @include media-breakpoint-up(xxl) {
+ right: 5%;
+ }
}
&-div {
@@ -643,8 +651,16 @@
background-color: $color-hex-medium-blue;
}
+ .text-light-blue {
+ color: $color-hex-medium-blue;
+ }
+
+ .title-wrapper {
+ margin-top: -2rem;
+ }
+
.titre-le-jeu-des-40-ans {
- position: absolute;
+ // position: absolute;
z-index: 2;
top: -.5rem;
left: 11%;
@@ -656,22 +672,19 @@
}
.titre-100-gagnant {
- position: absolute;
- z-index: 3;
- top: 1.7rem;
- left: 19%;
+ margin-left: 3rem;
transform: rotate(-2deg);
@include media-breakpoint-up(md) {
- top: 2.1rem;
- left: 50%;
- transform: translateX(-50%) rotate(-2deg);
+ top: 2.7rem;
+ left: 3.5rem;
+ transform: rotate(-2deg);
}
}
.sous-titre-rendez-vous {
max-width: 100%;
- margin-top: 100px;
+ margin-top: 3rem;
@include media-breakpoint-up(md) {
max-width: 65%;
@@ -679,8 +692,12 @@
}
.picto-temps-fort-1 {
- @include media-breakpoint-up(lg) {
- max-width: 352px;
+ .highlight-top {
+ margin-bottom: -0.5rem !important;
+ }
+
+ .highlight-bottom {
+ margin-top: -0.5rem !important;
}
}
@@ -860,16 +877,8 @@
top: -13%;
left: 33%;
max-width: 190px;
- transform: rotate(40deg);
@include media-breakpoint-up(md) {
- top: -4%;
- left: 4%;
- max-width: 317px;
- transform: rotate(-45deg);
- }
-
- @include media-breakpoint-up(lg) {
top: -4%;
left: 4%;
max-width: 317px;
@@ -1092,17 +1101,21 @@
&-cadeau-bleu {
position: absolute;
z-index: -1;
- top: 0;
+ top: 4rem;
right: 0;
max-width: 90px;
transform: translate(1%, 117%);
@include media-breakpoint-up(md) {
+ top: 10rem;
+ right: -15rem;
max-width: 109px;
transform: translate(-12%, 84%);
}
@include media-breakpoint-up(lg) {
+ top: 0;
+ right: 0;
transform: translate(-17%, 21%);
}
}
diff --git a/resources/views/components/fo/page-des-40-ans/section1/index.blade.php b/resources/views/components/fo/page-des-40-ans/section1/index.blade.php
index c7a75de1..c210e136 100644
--- a/resources/views/components/fo/page-des-40-ans/section1/index.blade.php
+++ b/resources/views/components/fo/page-des-40-ans/section1/index.blade.php
@@ -5,6 +5,6 @@
- Comment + {{ __('40years.how-to') }}
- Participer ? + {{ __('40years.play') }}