-1
I was wondering if there is any way to simulate that Firebase system (which is not yet compatible with PHP) to receive the information from the database in real time. I’m using Laravel, I collect the information by Controller and send it to view via array. I know there is a Broadcasting, but do not know if it would be the right option in this situation, also do not know very well how to implement. An example of the operation:
CONTROLLER:
function index(){
$database = app('firebase.database');
$drinks = $database->getReference('Drinks')->getSnapshot();
return view('welcome', [
'drinks' => $drinks->getValue()
]);
}
VIEW:
@foreach($drinks as $key => $drink)
<div class="row">
<div class="cell" data-title="Bebida">{{$drink['name']}}</div>
<div class="cell" data-title="Preço">R$ {{sprintf("%01.2f", $drink['price'])}}</div>
<div class="cell" data-title="Id">{{$key}}</div>
<div class="cell" data-title="Ações">
<div class="container-buttons">
<a href="delete/{{$key}}"><button type="button" class="btn btn-outline-danger">Excluir</button></a>
<a href="edit/{{$key}}"><button type="button" class="btn btn-outline-success">Editar</button></a>
</div>
</div>
</div>
@endforeach