Answer the question
In order to leave comments, you need to log in
Laravel: how to make a button to submit changes to DB?
Good afternoon! Please tell me how to make a button correctly so that when you click on it, 1 parameter in the database changes and a redirect to another page occurs.
Here is an example of a table where I created the data output. I can't figure out how to properly organize changes to the database on button click.
Answer the question
In order to leave comments, you need to log in
Duck call the controller method on the button and that's it.
You can use the get request, for example, the “to work” button is a link to the url “/work/id”, where id is the application number.
You can use a post request, then in the template you do Form:: open, the “to work” button is submit, and also add a hidden field with the application id. Well, in the controller you get the form and change the status.
Thanks a lot for the tip. I dug through a lot of information and came to the decision as you described. The button is a link to /tikets/{{id}}/work In the controller, I created a method that changes its status by the id of the record and everything turned out great!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question