Support the ongoing development of Laravel.io →
posted 10 years ago
Views
Last updated 2 years ago.
0

Search for View Composer

Last updated 2 years ago.
0

A controller is a class. So you can create a new instance and access its methods. E.g.:

$controller = new HomeController;
echo $controller->topRated();

However, the proper way is to either use View::share() or View::composer()

You could put a View::share in your constructor(s) to pass it to all your views:

View::share('topRated', $data);

Or look into View Composers for more advanced ways to share data with your views.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

andrejmk andrejmk Joined 28 Mar 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.