How to implement CRUD functions in the Laravel PHP Framework? Part-3

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