You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -62,11 +66,14 @@ Next you can modify the generated configuration file `tmdb.php` accordingly.
62
66
That's all! Fire away!
63
67
64
68
## Usage
69
+
65
70
We can choose to either use the `Tmdb` Facade, or to use dependency injection.
66
71
67
72
### Facade example
73
+
68
74
The example below shows how you can use the `Tmdb` facade.
69
75
If you don't want to keep adding the `use Tmdb\Laravel\Facades\Tmdb;` statement in your files, then you can also add the facade as an alias in `config/app.php` file.
76
+
70
77
```php
71
78
use Tmdb\Laravel\Facades\Tmdb;
72
79
@@ -81,6 +88,7 @@ class MoviesController {
81
88
```
82
89
83
90
### Dependency injection example
91
+
84
92
```php
85
93
use Tmdb\Repository\MovieRepository;
86
94
@@ -102,8 +110,10 @@ class MoviesController {
102
110
```
103
111
104
112
### Listening to events
113
+
105
114
We can easily listen to events that are dispatched using the Laravel event dispatcher that we're familiar with.
106
115
The following example listens to any request that is made and logs a message.
In Laravel 5 instead of using the `Event` facade we could also have used the `EventServiceProvider` to register our event listener.
119
130
120
131
### Image helper
132
+
121
133
You can easily use the `ImageHelper` by using dependency injection. The following example shows how to show the poster image of the 20 most popular movies.
122
134
123
135
```php
@@ -155,8 +167,10 @@ class WelcomeController extends Controller {
155
167
156
168
}
157
169
```
170
+
158
171
The `Configuration` used by the `Tmdb\Helper\ImageHelper` is automatically loaded by the IoC container.
159
172
If you are a Laravel 5.1 user you could also use the blade's `@inject` functionality,
173
+
160
174
```
161
175
@inject('image', 'Tmdb\Helper\ImageHelper')
162
176
@@ -166,7 +180,9 @@ If you are a Laravel 5.1 user you could also use the blade's `@inject` functiona
166
180
```
167
181
168
182
### Registering plugins
183
+
169
184
Plugins can be registered in a service provider using the `boot()` method.
0 commit comments