Good evening,
I'm learning Laravel and need to update a div every 10 seconds.
I have a route that, upon being called, makes a query to the database. This route returns the Dashboard view.
Route:
Route::get('/dashboard','DashboardController@buscarMmDia')->name('buscarMmDia');
In the view it processes the select and shows it on the screen:
<?php foreach ($buscarMmDia as $p): ?>
<div class="col s12 m3" id ="frase">
<div class="card-panel blue">
<div class="card-content center">
<img src="img/weather-rainy2.png">
<h5 class="white-text lighten-4">
<?= $p->mm ?>
</h5>
<p class="white-text lighten-4">Acumulados hoje.</p>
</div>
</div>
</div>
<?php endforeach ?>
Controller:
public function buscarMmDia(){
$buscarMmDia = DB::table('data_collect')
->select(DB::raw('count(*) as mm'))
->whereBetween('date_hour_col',array('2018-11-02 00:00:00','2018-11-02 23:59:59'))
->get();
return view('dashboard')->with('buscarMmDia', $buscarMmDia);
I need this div updated every 10 seconds. In other words, do the select again every 10 seconds.
What's the right way to do this?