0

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.

nooby98
  • 77
  • 6
  • Start there, it talk about HTTP request lifecyle https://stackoverflow.com/a/4814789/5543999 and then read this https://stackoverflow.com/a/49376645/5543999 – Elie Morin Mar 23 '21 at 19:48
  • It sounds like you are looking for a front-end framework. Check out React / Vue / Angular – HTMHell Mar 23 '21 at 20:30

1 Answers1

0

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.

timod
  • 585
  • 3
  • 13