1 | <?php namespace Modules\Recipe\Providers; |
||
5 | class RecipeServiceProvider extends ServiceProvider |
||
6 | { |
||
7 | /** |
||
8 | * Indicates if loading of the provider is deferred. |
||
9 | * |
||
10 | * @var bool |
||
11 | */ |
||
12 | protected $defer = false; |
||
13 | |||
14 | /** |
||
15 | * Register the service provider. |
||
16 | * |
||
17 | * @return void |
||
18 | */ |
||
19 | public function register() |
||
20 | { |
||
21 | $this->registerBindings(); |
||
22 | } |
||
23 | |||
24 | /** |
||
25 | * Get the services provided by the provider. |
||
26 | * |
||
27 | * @return array |
||
28 | */ |
||
29 | public function provides() |
||
30 | { |
||
31 | return array(); |
||
32 | } |
||
33 | |||
34 | private function registerBindings() |
||
35 | { |
||
36 | $this->app->bind( |
||
37 | 'Modules\Recipe\Repositories\RecipeRepository', |
||
38 | function () { |
||
39 | $repository = new \Modules\Recipe\Repositories\Eloquent\EloquentRecipeRepository(new \Modules\Recipe\Entities\Recipe()); |
||
40 | |||
41 | if (! config('app.cache')) { |
||
42 | return $repository; |
||
43 | } |
||
44 | |||
45 | return new \Modules\Recipe\Repositories\Cache\CacheRecipeDecorator($repository); |
||
46 | } |
||
47 | ); |
||
48 | // add bindings |
||
49 | |||
50 | } |
||
51 | } |
||
52 |