0

I want to render a partial view using:

@include('partial.view', array('view_data' => $view_data))

Now on this view I have a view composer:

View::composer('partial.view', 'TheController@theMethod');

The variable $view_data is visible inside the view, but not inside the view composer method that renders before the view.

I want to access $view_data (passed through @include) inside the @theMethod method. How can I achieve this? Maybe there is a different approach?

0

1 Answer 1

4

offsetGet() on the view lets you retrieve variables that have been injected into the view:

public function theMethod($view){
    $viewData = $view->offsetGet('view_data');
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.