In this video we are going to learn about Delete Service Category.\r
So let see how can we delete the service category.\r
For that switch to the project \r
And lets open the AdminServiceCategoryComponent class file and here\r
Lets create a function for deleting the service category\r
public function deleteServiceCategory($id)\r
$scategory = ServiceCategory::find($id);\r
if($ scategory ->image) \r
{ \r
unlink('images/categories'.'/'.$ scategory >image); \r
session()->flash('message’,’ServiceCategory has been deleted successfully!');\r
Now go to the AdminCategoryComponent view file \r
And here lets create a link\r
<a href=“#”wire:click.prevent=\"deleteServiceCategory({{$scategory->id}})\" style=\"margin-left:10px; \"><i class=\"fa fa-times fa-2x text-danger\"></i></a>\r
And inside this link call the delete service category function and pass the parameter id\r
One more thing add confirmation before deleteing the servicecategory\r
Here before this wire write here\r
<a href=\"#\" onclick=\"confirm('Are you sure, You want to delete this category?') || event.stopImmediatePropagation()\" wire:click.prevent=\"deleteServiceCategory({{$scategory->id}})\" style=\"margin-left:10px; \"><i class=\"fa fa-times fa-2x text-danger\"></i></a>\r
Now save this file\r
And lets check it\r
Switch to the browser and refresh the page\r
Now click on delete link\r
And here you can see the Service category has been deleted successfully\r
So in this way you can delete service category