V
V
Viktor Grachev2014-09-02 13:46:55
Laravel
Viktor Grachev, 2014-09-02 13:46:55

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.
c5d1936c61ec4f43b016d0ab55accc16.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Konstantin Andreevich, 2014-09-02
@azuron

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.

V
Viktor Grachev, 2014-09-02
@azuron

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 question

Ask a Question

731 491 924 answers to any question