Skip to content

Commit

Permalink
Request and Resource binding
Browse files Browse the repository at this point in the history
  • Loading branch information
reindert-vetter authored Aug 15, 2021
1 parent 7ba47ac commit bae009e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,20 @@ In a Version Middleware you can use Laravel Binding. So you can bind a FormReque

The `$request` can be either OrderIndexRequestV1 or OrderIndexRequestV2 and the `$resource` can be either OrderResourceV1 or OrderResourceV2.

You have to crate a BindOrderIndexRequestV1 and a BindOrderIndexRequestV2 middleware in which you will bind the request. The requests must extend the base class OrderIndexRequest. You can do the same for the resource class. The configuration will then look like this:
You have to create a BindOrderIndexRequestV1 and a BindOrderIndexRequestV2 middleware in which you will bind the request:
```php
class BindOrderIndexRequestV2
{
public function handle(Request $request, Closure $next)
{
app()->bind(OrderIndexRequest::class, OrderIndexRequestV2::class);

return $next($request);
}
}
```

The requests must extend the base class OrderIndexRequest. You can do the same for the resource class. The configuration will then look like this:
```php
'(GET)/orders' => [
'<=1' => [
Expand Down

0 comments on commit bae009e

Please sign in to comment.