Загрузка...

44. Laravel 13 E-Commerce Project - Admin Edit Coupon

Welcome back to the Laravel E-Commerce Project Tutorial! In this video, we will cover how to Edit the Coupon.

We start by opening the Coupon Controller to create a new `coupon_edit` function, which retrieves the specific coupon using `findOrFail` and passes it to the view. After setting up the GET route, we create the `coupon-edit.blade.php` view file by copying our existing add-coupon form.

You will learn how to update the form to handle updates by changing the action route and applying the `@method('PUT')` directive. We will walk through populating the form inputs with the existing coupon data using the `old()` helper, including a specific technique to format the expiry date using `\Carbon\Carbon::parse` so it displays correctly in the HTML date picker. Finally, we create the update function in the controller, define the PUT route, and add the edit link to our main coupons list.

If you found this video helpful, please subscribe and hit the bell icon to stay updated on the next parts of this series. Thanks for watching, and I’ll see you in the next video!
Topics Discussed in this Video:

1. Creating the `coupon_edit` function in the Coupon Controller using `findOrFail`.
2. Defining the GET route (`/admin/coupon-edit/{coupon_id}`) for the edit page.
3. Creating the `coupon-edit.blade.php` view file using the existing add-coupon form layout.
4. Updating the form action to target the update route and adding the `@method('PUT')` directive.
5. Populating form inputs (Code, Type, Value, Cart Value) with existing database values using the `old()` helper.
6. Formatting the existing expiry date for the HTML date input using `\Carbon\Carbon::parse() format('Y-m-d')`.
7. Creating the update function in the AdminController to save the changes.
8. Setting up the PUT route (`/admin/coupon/update`) in the web routes file.
9. Adding an edit link button to the main admin coupons view.
Your Queries:

1. How to edit and update records in a Laravel 13 admin panel?
2. How to pass existing database values into an HTML form using Laravel Blade?
3. How to use the `@method('PUT')` directive in a Laravel form?
4. How to format dates using Carbon for HTML date inputs in Laravel?
5. How to fetch a single record using `findOrFail` in a Laravel controller?
Template Url :
https://github.com/surfsidemedia/Laravel-13-E-Commerce-Project-Template
Project Source Code:

https://www.surfsidemedia.in/categories/laravel-13-e-commerce-project
FOLLOW SURFSIDE MEDIA:

https://www.facebook.com/SurfsideM/
https://twitter.com/MediaSurfside
https://github.com/surfsidemedia
https://surfsidemedia.tumblr.com/

#laravel #laravel13 #laravel13x

Видео 44. Laravel 13 E-Commerce Project - Admin Edit Coupon канала Surfside Media
Яндекс.Метрика
Все заметки Новая заметка Страницу в заметки
Страницу в закладки Мои закладки
На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.
О CookiesНапомнить позжеПринять