How to implement CRUD functions in the Laravel PHP Framework?
In previous blog Part-2, We have seen create() store() and index() functions.
Step 18. Go to app/Http/Controller/CustomerServiceController.php and in that we have to write code within edit() method and update(). Here edit() method will load edit form view file in browser and update() will update edit view file form data.
public function edit($id)
{
$service = Service::where('service_id',$id)->first();
return view('service.edit', compact('service'));
}
Step 19. To Delete data first we have to make delete URL in resources/views/Service/index.blade.php.
Step 20. To Delete particular service data based on the value of id which has passed in delete link form. Write the following code within the destroy() method.
public function destroy($id)
{
$service = Service::where('service_id', $id);
$service->delete();
return redirect()->route('service.index')->with('success', 'Data Deleted');
}
Now, we can add, edit and delete Customer Service Data
Thanks
- How to Login with Token in Laravel PHP Framework? - October 30, 2021
- How to merge two or multiple tables to each other in the Laravel PHP Framework? (Part-4) - October 29, 2021
- How to display a table in a Verticle or Horizontal form in the Laravel PHP Framework? Part-2 - October 29, 2021