Search code examples
phplaravellaravel-4template-enginelaravel-blade

How to render a template in a controller?


I have a blade template called 'main' and I wonder how I can render a sub template by calling a controllers method in my main template. Lets say I have a Controller WidgetsController with a method getSubView. The method returns a specific view with some data from (for instance) a database.

I already tried to @include a template but this will not call the controller which sets some necessary data to the view.

Thanks.


Solution

  • I don't entirely understand your question.

    I think what you are looking for is a View Composer

    It allows you to get data for a subview without having to create the data in every controller.