You have various options. This could be a good way:
<?php namespace Acme\Composers;
class UserComposer
{
public function compose($view)
{
$view->with('user', 'ipalaus');
}
}
Then, you should register your composers:
<?php namespace Acme\Composers;
class ComposersServiceProvider extends \Illuminate\Support\ServiceProvider {
public function register()
{
$view = $this->app['view'];
$view->composer('users', 'Acme\Composers\UserComposer');
}
}
$this->app->view->composer('users', 'Acme\Support\Composers\UserComposer');
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community