In Part-204 of the Laravel E-commerce series, we will continue working on the Wishlist functionality for our Laravel E-commerce website.
In this video, we will create a user wishlist page and show products added by the user to his wishlist.
1) Update front_header.blade.php file:-
First of all, show the Wishlist link at the front header before the Orders link at the front_header.blade.php file.
2) Create Route:-
Now create GET route for wishlist page in front auth middleware group in web.php file like below:-
// User Wishlist Products
Route::get('/wishlist','ProductsController@wishlist');
3) Create wishlist function:-
Now create a wishlist function in ProductsController similar to the cart function in which we will call the user wishlist function that we will create in the next step.
4) Create userWishlist function:-
Now create userWishlist function at the Wishlist model in which we will get user wishlist products with some product details.
5) Create product function (relation) :-
We will also create a product function in the Wishlist model to make belongsTo relation and get the product details from the product id that is stored in the wishlists table.
6) Create wishlist.blade.php and wishlist_items.blade.php files
We will now create wishlist.blade.php and wishlist_items.blade.php files to show wishlists products. We will include the wishlist_items.blade.php file within the wishlist.blade.php file to show wishlist products in foreach loop with some product details and view/delete buttons.
Now check-in video; we able to show user wishlist products in wishlists page.
Join this channel to get complete code/support:-
/ @stackdevelopers