Skip to content

Commit a8c56ce

Browse files
committed
Merge branch 'release/3.3.0'
2 parents 94d05e1 + 69c80c5 commit a8c56ce

File tree

4 files changed

+39
-13
lines changed

4 files changed

+39
-13
lines changed

1.0/getting-started/core-concepts.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
Your Laravel application can have any number of JSON:API compliant
88
APIs. We refer to each API as a **Server**.
99

10-
You may not use multiple servers: a simple application
11-
may only have one server. However, there are a number of use cases where
12-
you may decide to implement multiple servers. For example:
10+
You may opt to not use multiple servers: a simple application will
11+
typically only have one server. However, there are a number of use cases
12+
where you may decide to implement multiple servers. For example:
1313

1414
- If you have a public-facing API, and a private API (e.g. only accessible
1515
by administrators).

2.0/getting-started/core-concepts.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
Your Laravel application can have any number of JSON:API compliant
88
APIs. We refer to each API as a **Server**.
99

10-
You may not use multiple servers: a simple application
11-
may only have one server. However, there are a number of use cases where
12-
you may decide to implement multiple servers. For example:
10+
You may opt to not use multiple servers: a simple application will
11+
typically only have one server. However, there are a number of use cases
12+
where you may decide to implement multiple servers. For example:
1313

1414
- If you have a public-facing API, and a private API (e.g. only accessible
1515
by administrators).

3.0/getting-started/core-concepts.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
Your Laravel application can have any number of JSON:API compliant
88
APIs. We refer to each API as a **Server**.
99

10-
You may not use multiple servers: a simple application
11-
may only have one server. However, there are a number of use cases where
12-
you may decide to implement multiple servers. For example:
10+
You may opt to not use multiple servers: a simple application will
11+
typically only have one server. However, there are a number of use cases
12+
where you may decide to implement multiple servers. For example:
1313

1414
- If you have a public-facing API, and a private API (e.g. only accessible
1515
by administrators).

3.0/routing/README.md

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,10 +340,20 @@ use the `middleware` method:
340340
$server->resource('posts')->middleware('my_middleware1', 'my_middleware2');
341341
```
342342

343-
:::tip
344-
If you want to add middleware to specific resource actions, you should
345-
use [Controller middleware.](https://laravel.com/docs/controllers#controller-middleware)
346-
:::
343+
Alternatively, you can specify middleware per resource action. To do that,
344+
provide an array to the `middleware()` method. Middleware that applies to
345+
every action should use the `"*"` key. Middleware for a specific action
346+
should be keyed by that action.
347+
348+
For example:
349+
350+
```php
351+
$server->resource('posts')->middleware([
352+
'*' => 'my_middleware1', // applies to all actions
353+
'show' => 'my_middleware2', // apples to just the "show" action
354+
'store' => ['my_middleware3', 'my_middleware4'], // use arrays for multiple
355+
]);
356+
```
347357

348358
## Defining Relationships
349359

@@ -449,6 +459,22 @@ The following example adds middleware to our `tags` relationship routes:
449459
$relationships->hasMany('tags')->middleware('my_middleware1', 'my_middleware2');
450460
```
451461

462+
Alternatively, you can specify middleware per relationship action. To do that,
463+
provide an array to the `middleware()` method. Middleware that applies to
464+
every relationship action should use the `"*"` key. Middleware for a specific
465+
action should be keyed by that action. Use our short-hands of `related`,
466+
`show`, `update`, `attach` and `detach` for the actions:
467+
468+
For example:
469+
470+
```php
471+
$relationships->hasMany('tags')->middleware([
472+
'*' => 'my_middleware1', // applies to all actions
473+
'show' => 'my_middleware2', // apples to just the "show" action
474+
'update' => ['my_middleware3', 'my_middleware4'], // use arrays for multiple
475+
]);
476+
```
477+
452478
## Route Model Binding
453479

454480
By default Laravel takes care of substituting parameter values for models using

0 commit comments

Comments
 (0)