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
@@ -46,11 +66,14 @@ Next you can modify the generated configuration file `tmdb.php` accordingly.
46
66
That's all! Fire away!
47
67
48
68
## Usage
69
+
49
70
We can choose to either use the `Tmdb` Facade, or to use dependency injection.
50
71
51
72
### Facade example
73
+
52
74
The example below shows how you can use the `Tmdb` facade.
53
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
+
54
77
```php
55
78
use Tmdb\Laravel\Facades\Tmdb;
56
79
@@ -65,6 +88,7 @@ class MoviesController {
65
88
```
66
89
67
90
### Dependency injection example
91
+
68
92
```php
69
93
use Tmdb\Repository\MovieRepository;
70
94
@@ -86,8 +110,10 @@ class MoviesController {
86
110
```
87
111
88
112
### Listening to events
113
+
89
114
We can easily listen to events that are dispatched using the Laravel event dispatcher that we're familiar with.
90
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.
103
130
104
131
### Image helper
132
+
105
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.
106
134
107
135
```php
@@ -139,8 +167,10 @@ class WelcomeController extends Controller {
139
167
140
168
}
141
169
```
170
+
142
171
The `Configuration` used by the `Tmdb\Helper\ImageHelper` is automatically loaded by the IoC container.
143
172
If you are a Laravel 5.1 user you could also use the blade's `@inject` functionality,
173
+
144
174
```
145
175
@inject('image', 'Tmdb\Helper\ImageHelper')
146
176
@@ -150,7 +180,9 @@ If you are a Laravel 5.1 user you could also use the blade's `@inject` functiona
150
180
```
151
181
152
182
### Registering plugins
183
+
153
184
Plugins can be registered in a service provider using the `boot()` method.
0 commit comments