to show in header menu my products of my cart session, I'm passing the session "cart" from my controller to my view, like this:
FrontController:
public function index()
{
$cart = \Session::get('cart');
return view('index',compact('cart'));
}
Routes.php
Route::get('/','FrontController@index');
my layout principal.blade.php ( it work well)
@foreach ($cart as $item)
all items of my session cart
@endforeach
MY QUESTION:
there is a way to pass the cart session directly to all my views?? OR I must always pass the cart Session for each view ? i have about 24 views, i must do each view like my view homepage index.php ??
Thank you for your help!
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire