문제

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.

도움이 되었습니까?

해결책 2

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.

다른 팁

views don't call services, they only take variables and put them on screen for presentation.

you're on the good side with @include(). you only need to gather the infos for that sub view beforehand in the controller, and pass it to the View::make('main')->with($vars).

you may also consider using another <?= View::make('subview')->with($vars->sub);?> within the the view. or just use the @extend functionality.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top