I am looking for a way to edit the data before submitting it for viewing.
Quick example (just for demonstration): Let's say I pass the variable $namefor viewing through the controller. I would like to use something to pass another variable $messagethat will contain Hello $name, therefore, for example, Hello John, if the variable $nameis John.
I donโt want to send this second variable to the controller, because I am going to use a lot of controllers, views and what I want to do with the data is quite difficult.
I need to use this for both variables view("foobar", ["foo" => "bar"])and sessions view("foobar")->with("foo", "bar").
I tried to use both Middleware and Service Provider, but the problem was that I could not access the data being sent.
The only possible solution that I can think of now is to use the View layout, which I will include in each view, and which will convert the variables (using something like <? $message = "Hello $name"; ?>in the view), but that doesnโt mean t seems like the correct MVC solution for me.
Thank you all for your answers!
source
share