php - laravel execute code after return

776

Solution:

Using Laravel, you can run such tasks after sending the response to the user. It works by keeping the PHP process alive to run the tasks after closing the connection with the browser. You can do that using:

Job::dispatchAfterResponse() using Laravel v6.14.0 or higher.

883

Answer

Solution:

You are thinking about the problem the wrong way. You don't need to update the data after the view has been displayed; instead of this, simply let the view know about what is going on.

Presumably right now the view knows if a message is unread or not by comparing some timestamp with alast_viewed value that it gets by reaching directly into$conversation. Don't do that. Save the previouslast_viewed value before you update the database into a variable, pass that variable into the view and have the view compare with that.

People are also looking for solutions to the problem: can any one help to me to get variable from jquery and use in php

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.