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');
}
Code language: PHP (php)


Step 13. Go to routes/web.php file ,we have to define route of this all CustomerServiceController CRUD functions.
Route::resource('service','ServiceController');
Code language: PHP (php)

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'));
}
Code language: PHP (php)

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



With MotoShare.in, you can book a bike instantly, enjoy doorstep delivery, and ride without worries. Perfect for travelers, professionals, and adventure enthusiasts looking for a seamless mobility solution.