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
- 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