cleanup backend view shares

This commit is contained in:
Olivier Legat 2022-05-13 13:25:28 +02:00
parent 7648291bd0
commit 08b6e155a3
No known key found for this signature in database
GPG key ID: E6DCE8D1E33A5803
2 changed files with 6 additions and 61 deletions

View file

@ -5,14 +5,9 @@ namespace App\Http\Middleware;
use App\Enums\Page;
use App\Models\Advice;
use App\Models\Encart;
use App\Models\Moment;
use App\Models\Picto;
use App\Models\PictoBrand;
use App\Models\Post;
use App\Models\Product;
use App\Models\Text;
use App\Models\Title;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\View;
use Closure;
use Illuminate\Http\Request;
@ -30,8 +25,6 @@ class BackEndGlobals
{
$encart_home = Encart::where('page', Page::homeHeader()->value)->first();
$encart_marqueHeader = Encart::where('page', Page::marqueHeader()->value)->first();
// $encart_marqueBloc2 = Encart::where('page', Page::marqueBloc2()->value)->first();
// $encart_marqueBloc3 = Encart::where('page', Page::marqueBloc3()->value)->first();
$encart_marqueBloc4l = Encart::where('page', Page::marqueBloc4l()->value)->first();
$encart_marqueBloc4r = Encart::where('page', Page::marqueBloc4r()->value)->first();
$encart_marqueFooter = Encart::where('page', Page::marqueFooter()->value)->first();
@ -39,28 +32,8 @@ class BackEndGlobals
$mentions_legales = Text::where('page', Page::mentions()->value)->first();
$privacy_policy = Text::where('page', Page::charte()->value)->first();
$pictobrands_marque = PictoBrand::all();
$advice_news = Advice::all()->first();
$posts = Post::where([
['date_start', '<=', Carbon::now()->format('Y-m-d H:i:s')],
['date_end', '>', Carbon::now()->format('Y-m-d H:i:s')],
])
->orderBy('created_at', 'DESC')
->get();
$post_home = Post::where([
['date_start', '<=', Carbon::now()->format('Y-m-d H:i:s')],
['date_end', '>', Carbon::now()->format('Y-m-d H:i:s')],
['on_top', true]
])->first();
// Limitation à 3 produits affichés sur la homepage
$products_home = Product::where('is_on_top', true)->take(3)->get();
// produits affichés sur la page news
$products_news = Product::where('is_news', true)->get();
// Produits affichés sur la page Food Service
$products_food = Product::where('is_food_service', true)->get();
$pictos_marqueBloc2 = Picto::where('page', Page::marqueBloc2()->value)->get();
$pictos_food = Picto::where('page', Page::foodBloc2()->value)->get();
@ -71,26 +44,12 @@ class BackEndGlobals
$title_foodBloc2 = Title::where('page', Page::foodBloc2()->value)->first();
$title_newsPosts = Title::where('page', Page::newsPosts()->value)->first();
$moments = Moment::where('page', Page::marqueHistory()->value)->get();
View::share('encart_home', $encart_home);
View::share('encart_marqueHeader', $encart_marqueHeader);
// View::share('encart_marqueBloc2', $encart_marqueBloc2);
// View::share('encart_marqueBloc3', $encart_marqueBloc3);
View::share('encart_marqueBloc4l', $encart_marqueBloc4l);
View::share('encart_marqueBloc4r', $encart_marqueBloc4r);
View::share('encart_marqueFooter', $encart_marqueFooter);
View::share('encart_food', $encart_food);
View::share('pictobrands_marque', $pictobrands_marque);
View::share('post_home', $post_home);
View::share('posts', $posts);
View::share('products_home', $products_home);
View::share('products_news', $products_news);
View::share('products_food', $products_food);
View::share('advice_news', $advice_news);
View::share('pictos_marqueBloc2', $pictos_marqueBloc2);
@ -103,8 +62,6 @@ class BackEndGlobals
View::share('title_foodBloc2', $title_foodBloc2);
View::share('title_newsPosts', $title_newsPosts);
View::share('moments', $moments);
View::share('mentions_legales', $mentions_legales);
View::share('privacy_policy', $privacy_policy);

View file

@ -2,17 +2,6 @@
namespace App\Http\Middleware;
use App\Enums\Page;
use App\Models\Advice;
use App\Models\Encart;
use App\Models\Moment;
use App\Models\Picto;
use App\Models\PictoBrand;
use App\Models\Post;
use App\Models\Product;
use App\Models\Text;
use App\Models\Title;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\View;
use Closure;
use Illuminate\Http\Request;
@ -31,13 +20,12 @@ class FrontEndGlobals
{
//header menu
$currentRoute = Route::current()->getName();
$routeParamsFR = Route::current()->parameters();
$routeParamsEN = $routeParamsFR;
$routeParamsES = $routeParamsFR;
$routeOriginalParams = Route::current()->originalParameters();
array_walk($routeParamsFR, array($this, 'unbind'),'');
array_walk($routeParamsEN, array($this, 'unbind'),'en');
array_walk($routeParamsES, array($this, 'unbind'),'es');
$routeParamsFR = Route::current()->parameters();
$routeParamsEN = $routeParamsFR;
$routeParamsES = $routeParamsFR;
array_walk($routeParamsFR, array($this, 'unbind'),'');
array_walk($routeParamsEN, array($this, 'unbind'),'en');
array_walk($routeParamsES, array($this, 'unbind'),'es');
if (preg_match('/^(en|es)/', $currentRoute )) {
$currentRouteFR = preg_replace('/^(en|es)\./', '', $currentRoute,1);
$currentRouteEN = preg_replace('/^(en|es)/', 'en', $currentRoute,1);