Ad

Getting Variables In A View Composer?

- 1 answer

I share vars with my views like so:

View::share(['test' => $this->test]);

How can I get the above value in my view composer?

I am aware of the getData method but this only works with data set like:

return view('my-view')->withData($data);

How can I get the 'test' value in my view composer?

Ad

Answer

The answer is:

$view->getFactory()->shared('shared_var')
Ad
source: stackoverflow.com
Ad