Laravel 9 Tutorial #118 | Laravel Helper | Create Helper Function for Cart Items Count

preview_player
Показать описание
In Part 118 of the Laravel 9 Tutorial to create a Multi-Vendor E-commerce Website in Laravel 9, we will create Helpers where we can create all common functions.

We will create common function totalCartItems in Helpers file that we can use anywhere in our website to show total items added in user shopping cart.

3) Run below composer command :-
composer dump-autoload

4) Create totalCartItems function :-

5) Include Cart model :-

7) Update cartUpdate function :-
Now we will update cartUpdate function located at ProductsController to call totalCartItems function to get total cart items count and return to Ajax response from where we will display with class totalCartItems.

8) Update cartDelete function :-
Now we will update cartDelete function to call totalCartItems function to get total cart items count and return to Ajax response from where we will display with class totalCartItems.

Now check in video, We able to show total cart items count at header, sidebar and in shopping cart. Count updates without refresh.

Popular Stack Developers Series that can help you:-

►Join this channel to get the complete source code of all series:

Follow Stack Developers on Social Media to get updates and resolve your queries

#laravel9 #laravel9tutorial #laravel
Рекомендации по теме
Комментарии
Автор

Sir why don't you create the function in the Model and call it in the View but you have to use helpers ?

Great tutorial, great lecturing...You are just amazing. How I wish you were teaching Java or C#

henrynanabeyinagyapong
Автор

In This Series when will be the next video come? i mean video no.140

md.ishrakislam
welcome to shbcf.ru