How can I refresh a page when a database is updated in Laravel?
-
What do you mean? Explain more – Murlidhar Fichadia Jun 20 '16 at 22:45
-
please explain more, insert your controller ? – Diego Cespedes Jun 20 '16 at 22:46
-
Like earlier one asked: you need to be more specific. If you don't have access to your database completely - that's one case, and I doubt, that anything could be done. If it's just a part of page that you want to refresh using ajax, then you could return some default value based on request timeout. – arunas_t Jun 20 '16 at 22:49
-
Using a WebSocket. – no ai please Sep 02 '21 at 01:17
2 Answers
Thats a rough...open ended question. But here's a stab at it.
Often - the client makes requests to the server to receive state information. Often its referred to as "client-server architecture" (somewhat erroneously imo).
E.g - Timmy refreshes his webpage and sees different content because the content has changed since the last time he made a request to the server.
Typically - when you want to have a server-client (again...not entirely accurate use of the term) style of communication it requires you to have a socket open with that client. Seeing how you mentioned Laravel, see: https://laracasts.com/discuss/channels/general-discussion/step-by-step-guide-to-installing-socketio-and-broadcasting-events-with-laravel-51
Socket libraries often have an "event emitting/broadcasting" behavior. This would allow you to achieve something like notifying a given client that something has changed in your database :)
Other resources:
Does anybody still use Client Server Architecture
http://www.tutorialspoint.com/unix_sockets/what_is_socket.htm
What is the difference between a web application and a client/server application?

- 1
- 1

- 1,469
- 1
- 15
- 24
Not 100% sure what you need but you probably should to go with Javascript - using AJAX to monitor your tables with certain intervals, and the reload the page when your criteria is met.

- 7,470
- 9
- 39
- 55