cleanup sitewide view shares

This commit is contained in:
Olivier Legat 2022-05-13 13:19:40 +02:00
parent 739320b334
commit 7648291bd0
No known key found for this signature in database
GPG key ID: E6DCE8D1E33A5803
8 changed files with 72 additions and 91 deletions

View file

@ -3,7 +3,11 @@
namespace App\Http\Controllers;
use App\Enums\Page;
use App\Models\Encart;
use App\Models\Picto;
use App\Models\Product;
use App\Models\SeoDatum;
use App\Models\Title;
use Illuminate\Http\Request;
class FoodServiceController extends Controller
@ -13,6 +17,12 @@ class FoodServiceController extends Controller
$page = Page::foodservice();
$seoDatum = SeoDatum::where('page',$page)->first();
return view('front.food-service', compact('seoDatum'));
$encart_food = Encart::where('page', Page::foodHeader()->value)->first();
$title_foodBloc2 = Title::where('page', Page::foodBloc2()->value)->first();
$pictos_food = Picto::where('page', Page::foodBloc2()->value)->get();
$products_food = Product::where('is_food_service', true)->get();
return view('front.food-service', compact('seoDatum' , 'encart_food', 'title_foodBloc2',
'pictos_food', 'products_food'));
}
}

View file

@ -3,6 +3,9 @@
namespace App\Http\Controllers;
use App\Enums\Page;
use App\Models\Encart;
use App\Models\Post;
use App\Models\Product;
use App\Models\SeoDatum;
use App\Models\Slide;
use App\Models\Slider;
@ -32,9 +35,20 @@ class HomeController extends Controller
});
})->orderBy('order', 'ASC')
->get();
return view('front.home', compact('slider', 'slides', 'seoDatum'));
} else {
return view('front.home', compact('slider', 'seoDatum'));
$slides = null;
}
$encart_home = Encart::where('page', Page::homeHeader()->value)->first();
$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();
return view('front.home', compact('slider', 'slides', 'seoDatum', 'encart_home', 'post_home', 'products_home'));
}
}

View file

@ -17,6 +17,6 @@ class LegalsController extends Controller
$seoDatum = new SeoDatum();
$seoDatum->title = $mentions_legales->title;
return view('front.legals', compact('seoDatum'));
return view('front.legals', compact('seoDatum' ,'mentions_legales'));
}
}

View file

@ -3,7 +3,12 @@
namespace App\Http\Controllers;
use App\Enums\Page;
use App\Models\Encart;
use App\Models\Moment;
use App\Models\Picto;
use App\Models\PictoBrand;
use App\Models\SeoDatum;
use App\Models\Title;
use Illuminate\Http\Request;
class MarqueController extends Controller
@ -13,6 +18,19 @@ class MarqueController extends Controller
$page = Page::marque();
$seoDatum = SeoDatum::where('page',$page)->first();
return view('front.a-propos', compact('seoDatum'));
$encart_marqueHeader = Encart::where('page', Page::marqueHeader()->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();
$pictobrands_marque = PictoBrand::all();
$pictos_marqueBloc2 = Picto::where('page', Page::marqueBloc2()->value)->get();
$title_marqueBloc2 = Title::where('page', Page::marqueBloc2()->value)->first();
$title_marqueBloc4 = Title::where('page', Page::marqueBloc4()->value)->first();
$moments = Moment::where('page', Page::marqueHistory()->value)->get();
return view('front.a-propos', compact('seoDatum', 'encart_marqueHeader', 'encart_marqueBloc4l',
'encart_marqueBloc4r', 'encart_marqueFooter', 'pictobrands_marque', 'title_marqueBloc2',
'pictos_marqueBloc2', 'moments', 'title_marqueBloc4'));
}
}

View file

@ -3,8 +3,14 @@
namespace App\Http\Controllers;
use App\Enums\Page;
use App\Models\Advice;
use App\Models\Post;
use App\Models\Product;
use App\Models\SeoDatum;
use App\Models\Text;
use App\Models\Title;
use Illuminate\Http\Request;
use Illuminate\Support\Carbon;
class NewsController extends Controller
{
@ -13,6 +19,19 @@ class NewsController extends Controller
$page = Page::news();
$seoDatum = SeoDatum::where('page',$page)->first();
return view('front.news', compact('seoDatum'));
$advice_news = Advice::all()->first();
$texts_news = Text::where('page', Page::newsQuestions()->value)->get();
$title_newsPosts = Title::where('page', Page::newsPosts()->value)->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();
$products_news = Product::where('is_news', true)->get();
return view('front.news', compact('seoDatum', 'advice_news' , 'texts_news', 'title_newsPosts', 'posts', 'products_news'));
}
}

View file

@ -17,6 +17,6 @@ class PolicyController extends Controller
$seoDatum = new SeoDatum();
$seoDatum->title = $privacy_policy->title;
return view('front.policy', compact('seoDatum'));
return view('front.policy', compact('seoDatum', 'privacy_policy'));
}
}

View file

@ -30,8 +30,8 @@ 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_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();
@ -75,8 +75,8 @@ class BackEndGlobals
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_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 file

@ -29,86 +29,6 @@ class FrontEndGlobals
*/
public function handle(Request $request, Closure $next)
{
$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();
$encart_food = Encart::where('page', Page::foodHeader()->value)->first();
$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();
$texts_news = Text::where('page', Page::newsQuestions()->value)->get();
$title_marqueBloc2 = Title::where('page', Page::marqueBloc2()->value)->first();
$title_marqueBloc4 = Title::where('page', Page::marqueBloc4()->value)->first();
$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);
View::share('pictos_food', $pictos_food);
View::share('texts_news', $texts_news);
View::share('title_marqueBloc2', $title_marqueBloc2);
View::share('title_marqueBloc4', $title_marqueBloc4);
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);
//header menu
$currentRoute = Route::current()->getName();
$routeParamsFR = Route::current()->parameters();