In this video we are going to learn about Delete Service
So let see how can we Delete the Service
Switch to the project and lets open AdminServcieComponent Class file
And here lets create a function for deleting the service


public function deleteService($service_id)
{
$service = Service::find($service_id);
if($service->thumnail)
{
unlink('images/services/thubnails'. '/' . $service->thumbnail);
}
if($service->image)
{
unlink('images/services'. '/' . $service->image);
}
$service->delete();
session()->flash('message','Service has been deleted successfully!');
}


Now go to the view file and before the form add the following code for showing the confirmation message

@if(Session::has('message'))
<div class=\"alert alert-success\" role=\"alert\"> {{Session::get('message’)}} </div>
@endif

and call the deleteService function on click event inside the table row so write the following code

<a href=\"#\" onclick=\"confirm('Are you sure, you want to delete this service?') || event.stopImmediatePropagation()\" style=\"margin-left:10px;\" wire:click.prevent=\"deleteService({{$service->id}})\"><i class=\"fa fa-times fa-2x text-danger\"></i></a>

Now lets check this so go to the admin/all-services
and here click on delete link and after confirmation record will be deleted.
So in this way you can Delete Service