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
> NOTE: Check `PPSpaces\Repositories\Model` for available methods that you may override. Keep in mind that you still have access to all Model instance that you've created. The `$this->user` is the instance of your `\App\User` model.
115
135
116
-
Within your `UserController` assume you have a resource controller created. Inject the `UserRepository` to the contoller.
136
+
Within your `UserController` assume you have a resource controller created. Inject the `UserRepository` to the contoller. Now you can access the repository in your controller method:
117
137
118
138
```php
119
139
use App\Http\Repositories\UserRepository;
@@ -126,15 +146,31 @@ class UserController extends Controller
126
146
{
127
147
$this->users = $users;
128
148
}
149
+
150
+
public function index()
151
+
{
152
+
return $this->users->all();
153
+
}
129
154
}
130
155
```
131
156
132
-
Now you can access the repository in your controller method:
157
+
Or alternatively, you may use **Route Model Binding** on the controller actions whose `type-hinted` variable names match a route segment name.
158
+
159
+
> Read more about [Route Model Binding](https://laravel.com/docs/master/routing#route-model-binding) here
0 commit comments