Skip to content
Advertisement

Laravel 8 form to update database

I am creating a simple blog site with CRUD functionality in Laravel 8. I have done this before using the deprecated Laravel forms, but am now trying to do it using HTML forms.
However, I am having some problem with the update part of the website. I have a controller called BlogsController with this function to be called to update the blog in the database which should be called when the user submits the form to update.

BlogsController update function

JavaScript

What action does the form need to direct to?

Top of update form

JavaScript

Route in web.php

JavaScript

Implementation in Laravel forms

JavaScript

Advertisement

Answer

You can get a list of all your application routes and names by running

JavaScript

For your blog update route you should use

JavaScript

in your template.

Make sure you have you have your csrf token set correctly at your form by using the @csrf, see Laravel docs.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement