Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

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

How to implement CRUD functions in the Laravel PHP Framework?

In previous blog Part-1, We have seen that how we start to implement CRUD functions.

Step 12. Now, Go to app/Http/Controllers/CustomerServiceController.php. Here, we’ll see all predefined Crud function, so we have to write code only for CRUD to display view file in the browser within Create() function, and to insert data into the Mysql table within Store() function.

public function create()
    {
        return view('service.create');
    }

Step 13. Go to routes/web.php file ,we have to define route of this all CustomerServiceController CRUD functions.

Route::resource('service','ServiceController');

Step 14. Go to app/Service.php. Now, we need to list all the properties we need in the $fillable array.

Step 15. Go to app/Http/Controllers/ServiceController.php file and write following codes within index() function.

 public function index()
    {
       $services = Service::all()->toArray();
        return view('service.index', compact('services'));
    }

Step 16. To update Mysql table data, we have to make an edit link in resource/views/Service/ folder. So, create an index.blade.php file.

Step 17. Go to resources/views/Service folder and create edit.blade.php file. In this file, service data will be loaded.

Thanks