Skip to content

Instantly share code, notes, and snippets.

@sunnysingh
Created July 13, 2015 22:00
Show Gist options
  • Save sunnysingh/bb442b2b16a34ac2888c to your computer and use it in GitHub Desktop.
Save sunnysingh/bb442b2b16a34ac2888c to your computer and use it in GitHub Desktop.
<?php namespace App\Http\ViewComposers;
use Illuminate\Contracts\View\View;
use Auth;
class AppComposer {
/**
* Create a new app composer.
*/
public function __construct()
{
//
}
/**
* Bind data to the view.
*
* @param View $view
* @return void
*/
public function compose(View $view)
{
$view->with([
'user' => Auth::user(),
]);
}
}
<?php namespace App\Providers;
use View;
use Illuminate\Support\ServiceProvider;
class ComposerServiceProvider extends ServiceProvider {
/**
* Register bindings in the container.
*
* @return void
*/
public function boot()
{
// App composer
View::composer([
'settings.*',
// add your templates here that extend app
], 'App\Http\ViewComposers\AppComposer');
}
/**
* Register
*
* @return void
*/
public function register()
{
//
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment