I’m pretty new to Laravel and I’m trying to pass data from my controller to the view, which I managed to do as follows:
Controller:
$data['value1'] = 1; return view('main', $data);
main.blade.php:
{{value1}}
This works fine but now my question is what can I do if I want to change the value of value1
with another method of the controller without refreshing the page?
Are there different approaches or is there one which is most used in Laravel?
Thanks in advance.
Advertisement
Answer
Without refresh you need to implement a kind background task which pulls the data to frontend. You could do this out of the box with https://laravel-livewire.com/ or implement it via vuejs.