In this video we are going to learn about edit service category. So let see how can we edit the service category. So first of all lets create a new livewire component for edit the service category\r
in command prompt for creating the new livewire component execute the following command\r
\r
php artisan make:livewire admin/AdminEditServiceCategoryComponent\r
\r
Now lets create the route for the AdminEditServiceCategoryComponent\r
So go inside the routes directory then open web.php file and here lets add the route inside the AdminMiddleware route group.\r
\r
Route::get('/admin/service-category/edit/{category_slug}',AdminEditServiceCategoryComponent::class)->name('admin.edit_service_category');\r
\r
\r
Now open AdminEditServiceCategoryComponent Class File and first of all add the layout\r
\r
->layout('layouts.base');\r
\r
Now open the AdminAddServiceCategoryComponent View File and select all the text and paste inside the AdminEditServiceCategoryComponent View File\r
\r
Now go to the AdminEditServiceCategoryComponent Class File\r
And lets create some properties\r
\r
\r
public $category_id;\r
public $name;\r
public $slug;\r
Public $image;\r
Public $newimage;\r
\r
\r
Now go to the view file here change the property name and write here\r
Newimage also change here\r
Now inside the class file add mount lifecycle hook method\r
\r
\r
public function mount($category_id)\r
{\r
$category = Category::find($category_id);\r
$this->category_id = $category->id;\r
$this->name = $category->name;\r
$this->slug = $category->slug;\r
}\r
\r
Now add the function for generate slug\r
\r
public function generateslug()\r
{\r
$this->slug = Str::slug($this->name,'-');\r
}\r
\r
And now create function for updatecategory\r
\r
Now call this function on edit form submit \r
so go to the component view file and add the function name updateCategory\r
\r
Alright\r
Now open the AdminServiceCategoryComponent view file \r
And inside this table lets add the edit category link here\r
\r
<a href=\"{{route('admin.edit_service_category',['category_id’=>$scategory->id])}}\"><i class=\"fa fa-edit fa-2x text-info\"></i></a>\r
\r
Now its done so lets check it\r
switch to the browser and now edit any category lets edit this category\r
Now change the category name\r
Click on submit\r
And here you can see the message category updated\r
Now click on this link \r
And here you can see the category has been updated\r
So in this way you edit the service category