Laravel 10 Tutorial #107 | Laravel Add to Cart with Ajax (I) | Create carts Table | Add to Cart Form

Laravel 10 Tutorial #107 | Laravel Add to Cart with Ajax (I) | Create carts Table | Add to Cart Form

Stack Developers

7 месяцев назад

781 Просмотров

►Laravel 10 Tutorial Playlist: https://www.youtube.com/playlist?list=PLLUtELdNs2ZbX7T5wgbBR9wUXt5YPG-hm

In Part 107 of the Laravel 10 Tutorial to make the E-commerce Website in Laravel, we will start working on the Laravel add-to-cart functionality via Ajax in which the user will select the product size to add it to the shopping cart from the detail page.

In this video, we will create a carts table with Migration and a Model for the carts table. We will also create add to cart form for adding product to cart with ajax.

1) Create carts table:-
First of all, we will create a carts table with migration. Create migration file with name create_carts_table for creating carts table with below columns:-
id, session_id, user_id, product_id, product_size, product_qty, created_at, updated_at

So, we will run the below artisan command to create a migration file for carts:-
php artisan make:migration create_carts_table

Open the create_carts_table migration file and add all required columns mentioned earlier.

Now, we will run below artisan command below to create a carts table with the required columns:-
php artisan migrate

2) Create Cart model:-
Create a Cart model by running the below command:-
php artisan make:model Cart

3) Update detail.blade.php file :-
Create a cart form with product id, size, qty fields with the action add-to-cart to pass these values to addToCart function.

4) Create Route:-
Create POST route for add-to-cart in web.php file like below:-
// Add to Cart
Route::post('/add-to-cart','ProductController@addToCart');

5) Create addToCart function :-
Now create the addToCart function in ProductController and get the data from the add to cart form via Ajax.

In the next video, we will save the product data in the carts table via Ajax.

►Click here to subscribe for Laravel & other updates - https://www.youtube.com/stackdevelopers

Popular Stack Developers Series that can help you:-

►Laravel Multi-Vendor E-commerce Website - https://www.youtube.com/playlist?list=PLLUtELdNs2ZYTlQ97V1Tl8mirS3qXHNFZ

►React JS Tutorial for Beginners with Laravel - https://www.youtube.com/playlist?list=PLLUtELdNs2ZYnEIWliBpU98gtorNRNHw1

►Laravel Tutorial for Beginners - https://www.youtube.com/playlist?list=PLLUtELdNs2ZaHaFmydqjcQ-YyeQ19Cd6u

►GIT Tutorial for Beginners - https://www.youtube.com/playlist?list=PLLUtELdNs2ZZVQ-dLOMFWvmCCduzJ8c6R

►Laravel API Tutorial - https://www.youtube.com/playlist?list=PLLUtELdNs2ZbcCsd4yAAiBU2L3ROREk8P

►Laravel Interview Questions - https://www.youtube.com/playlist?list=PLLUtELdNs2ZbzB_1Jdp_yFcORwOfWP8RU

►jQuery Tutorial - https://www.youtube.com/playlist?list=PLLUtELdNs2ZbMYoUA46GIonOH29KcjtxA

►Laravel Basic E-commerce Series - https://www.youtube.com/playlist?list=PLLUtELdNs2ZY5drPxIWzpq5crhantlzp7

►Laravel Dating Series - https://www.youtube.com/playlist?list=PLLUtELdNs2ZZrPUnxjlomErJfNvkyS6Hf

►Join this channel to get the complete source code of all series:
https://www.youtube.com/channel/UCExO2i-tLU1NyVZD6zOJQlw/join

Follow Stack Developers on Social Media to get updates and resolve your queries
►Like Facebook Page to get updates - http://facebook.com/stackdevelopers2/
►Join Facebook Group to resolve your queries - http://facebook.com/groups/stackdevelopers
►Follow on Instagram - https://www.instagram.com/stackdevelopers2/
►Follow on GitHub - https://github.com/stackdevelopers

#laravel10 #laravel10tutorial #laravel

Тэги:

#laravel_10 #laravel_10_tutorial #make_admin_panel_in_laravel_10 #laravel_admin_panel #create_admin_in_laravel #admin_panel_laravel #make_admin_laravel #make_ecommerce_admin_laravel #laravel_10_ecommerce #products_module #create_admin_panel_in_php #create_products_table #products_laravel #images_laravel #Laravel_Add_to_Cart_with_Ajax #product_detail_page_laravel #laravel_add_to_cart #add_to_cart_with_ajax
Ссылки и html тэги не поддерживаются


Комментарии: