I’m using laravel 9 and i’m new to using the blade template view files.
I have an blade template file that shows a table and has some buttons to interact with that.
the table is just a result of select * from some_table, and i want it to be refreshed every second, i tried to google.. found broadcasting.. ajax… everything seems a bit too complicated for a simple task as this.
so I have a route at web.php
Route::get('/test-page', function () {
return view('test-page');
});
and test-page.blade.php contains:
<?php
$agents = IlluminateSupportFacadesDB::select('select * from agents');
?>
<!DOCTYPE html>
<html>
...
<table>
...
<tbody>
@foreach ($agents as $agent)
<tr>
<td>{{ $agent->id }}</td>
<td> {{ $agent->name }}</td>
...
</tr>
@endforeach
i want $agents variable to be refreshed every second, and the table display would changed accordantly without refreshing the all page. there must be a simple way to do just that.
i guess i can create a route that will return that data in a json format and return it, i’m sure there is a cool laravel way to resolve this just don’t know how or where to start really.
any information regarding this issue would be greatly appreciated.