Last active
February 17, 2017 14:29
-
-
Save Mombuyish/9dda8693b004e0759b4889855692b387 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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', Cache::remember('posts', 60 /* cache expired time(mins) */, function() { | |
return 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