Skip to content

Instantly share code, notes, and snippets.

@Mombuyish
Last active February 17, 2017 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mombuyish/0f2f9652e9d2dee65fa444efccf074f9 to your computer and use it in GitHub Desktop.
Save Mombuyish/0f2f9652e9d2dee65fa444efccf074f9 to your computer and use it in GitHub Desktop.
<?php
namespace App\Providers;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
class ComposerServiceProvider extends ServiceProvider
{
/**
* Register bindings in the container.
*
* @return void
*/
public function boot()
{
// Using Closure based composers...
// Here is a simple example...
View::composer('collections.index', function ($view) {
$view->with('posts', app(\App\Services\PostService::class)->all());
});
}
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
//
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment