Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
279 views
in Technique[技术] by (71.8m points)

laravel - Auto edit MySQL data after a given time

We have a form which is stored in draft mode. That means editing any data or deleting the entire form is possible. The beginning to end process is as follows

  • When a person tries to submit the form for the first time, that is stored in draft. (the isDraft column is set to 0)

  • The user is redirected to another page where s/he can view the Form id (a generated number), name, a few other details and Edit/Delete options.

  • The user can click edit button to edit anything, or even delete the form.

  • However this will be allowed till a given date (say 15 days from the first submission date). Once that date is passed, the form can no longer be edited or deleted. In case the form isn't deleted, the isDraft column is set to 1.

Thousands of people can submit the form . So ,it is not possible to do it manually.

Our project is done using Laravel v6.2, but I want a general idea as well .

I can use a trait or ajax on the master page, but that is too risky and also, server inaccessibility can delay the process, and some users may get an advantage.

How to do it?

If there is no concrete answer, but rather only discussion , I will remove this post

question from:https://stackoverflow.com/questions/65952785/auto-edit-mysql-data-after-a-given-time

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Not sure if I understand it correctly, but I think you like to update the updated_at timestamp automatically. You can run through the Eloquent Models by create a command and just call the save Method on them.

$model->save()


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...