Previous Video | Ecom Part 2:
In Part 3 of E-com series, we are going to edit the categories that we have added earlier in last videos. We will create 'edit category' page where all category data will be displayed of a particular category that the admin can edit and save.
1) Create Route :-
First create Route for edit category same like we did for add category. But now we will also pass category id in the Route.
Route::match(['get','post'],'/admin/edit-category/{id}','CategoryController
See we have passed category id in route with {id} at the end of edit category link /admin/edit-category/{id}
2) Create Function :-
Now we will add editCategory function in CategoryController and return its view.
In editCategory function as well, we will pass $id as one of the parameter along with $request.
3) Create Blade file :-
Now create edit_category.blade.php file in categories folder under admin folder that is under views folder in the same way in which we have created add category page earlier on.
See now in video, edit category page is created. Now we will add admin design to it and copy add category data as well. We will make changes in it.
See in video, now our edit category page is coming. Now we will show already added category data in it and also link it with edit tab in Categories page.
See in video, we have updated editCategory function. We get category details from category id that we want to edit and that details we will return to edit category form where admin can make changes.
See in video, now Category data is coming in edit category form.
Now we will update form action that we will pass to edit category function again with category id.
Now see edit form action link seems to be fine like
4) Update editCategory function
Now we will update editCategory function again to get the updated category data and update in categories table and then return with success update message.
See in video, now we able to successfully edit our categories and Success message comes once we edit it.
Also change the form id and add separate validations for edit form.
In next video, we will also add delete functionality to our categories and move to other things.
So stay tune for next video. Thanks for watching :)
Next Video | Ecom Part 4: