Correct me if I'm wrong (since you did not send a lot of data to understand you better), but I suppose you have something like that in your controller:
function controladorVista()
{
$mostrarusers = DB::table('votos')
->join('users','users.id','=','votos.user_id')
->join('nombre_votos','nombre_votos.id','=','votos.id_nombre_votos')
->select('users.name as usuario', 'nombre_votos.nombre as
proyecto','si','no','voto_en_blanco')
->whereDate('votos.created_at', Carbon::today())
->get()
return view('index', compact('mostrarusers'));
}
If so, I regret to say that your list will only be updated when you refresh (reload the page). Now starting from that the options that you have to update your page without needing to reload this would be:
1 - Make a request via ajax to a path / endpoint of your server in laravel, this will bring you your list and you will be able to update your table, for that you would have to add the function setInterval of js that executes it from time to time (such every 3 minutes).
On your controller:
function getMostrarUsers()
{
$mostrarusers = DB::table('votos')
->join('users','users.id','=','votos.user_id')
->join('nombre_votos','nombre_votos.id','=','votos.id_nombre_votos')
->select('users.name as usuario', 'nombre_votos.nombre as
proyecto','si','no','voto_en_blanco')
->whereDate('votos.created_at', Carbon::today())
->get();
return response()->json($mostrarusers, 200);
}
In your routes file (routes / web.php) by default
Route::get('/mostrar-users', 'TuControlador@getMostrarUsers')->name('rest.getMostrarUsers');
(In your view / view) Then in the part of your <scripts>
or a file js
external%, it would be more or less like this (Using JQuery
):
function cargarTabla(){
$.ajax({
url : '{{ route('rest.getMostrarUsers')}}',
method : 'GET',
success : function(r){
let lista = r;
let htmlCode = '';
$.each(lista, function(index, item){
htmlCode+='<tr>
<td>${item.nombreProyecto}</td>
<td>${totalDeSi}</td>
<td>${totalDeNo}</td>
<td>${totalVotoBlanco}</td>
</tr>';
});
$('#id-mi-tabla tbody').html(htmlCode);
}
});
}
In the same document using the document ready, you would load this function every so often:
$( document ).ready(function() {
setInterval(cargarTabla, 180000);//Cada 3 minutos (180 mil milisegundos)
});
2 - Use websockets, which would be optimal, with this you could configure that every time you do an insert / update / delete something related to your list (like a vote), I shot an event in laravel that is responsible for updating your table to all customers who subscribe to this. this would be in real time.