Skip to content

Commit 2791342

Browse files
docs(default-order): compatibility with laravel (#2072)
1 parent ec11e56 commit 2791342

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

core/default-order.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ customize this order, you must add an `order` attribute on your ApiResource anno
99

1010
```php
1111
<?php
12-
// api/src/Entity/Book.php
13-
namespace App\Entity;
12+
// api/src/ApiResource/Book.php with Symfony or app/ApiResource/Book.php with Laravel
13+
namespace App\ApiResource;
1414

1515
use ApiPlatform\Metadata\ApiResource;
1616

@@ -30,7 +30,8 @@ class Book
3030

3131
```yaml
3232
# api/config/api_platform/resources/Book.yaml
33-
App\Entity\Book:
33+
# The YAML syntax is only supported for Symfony
34+
App\ApiResource\Book:
3435
order:
3536
foo: ASC
3637
```
@@ -44,8 +45,8 @@ If you only specify the key, `ASC` direction will be used as default. For exampl
4445

4546
```php
4647
<?php
47-
// api/src/Entity/Book.php
48-
namespace App\Entity;
48+
// api/src/ApiResource/Book.php with Symfony or app/ApiResource/Book.php with Laravel
49+
namespace App\ApiResource;
4950
5051
use ApiPlatform\Metadata\ApiResource;
5152
@@ -70,7 +71,8 @@ class Book
7071

7172
```yaml
7273
# api/config/api_platform/resources/Book.yaml
73-
App\Entity\Book:
74+
# The YAML syntax is only supported for Symfony
75+
App\ApiResource\Book:
7476
order: ['foo', 'bar']
7577
```
7678

@@ -82,8 +84,8 @@ It's also possible to configure the default order on an association property:
8284

8385
```php
8486
<?php
85-
// api/src/Entity/Book.php
86-
namespace App\Entity;
87+
// api/src/ApiResource/Book.php with Symfony or app/ApiResource/Book.php with Laravel
88+
namespace App\ApiResource;
8789
8890
use ApiPlatform\Metadata\ApiResource;
8991
@@ -103,7 +105,8 @@ class Book
103105

104106
```yaml
105107
# api/config/api_platform/resources/Book.yaml
106-
App\Entity\Book:
108+
# The YAML syntax is only supported for Symfony
109+
App\ApiResource\Book:
107110
order: ['author.username']
108111
```
109112

@@ -115,8 +118,8 @@ Another possibility is to apply the default order for a specific collection oper
115118

116119
```php
117120
<?php
118-
// api/src/Entity/Book.php
119-
namespace App\Entity;
121+
// api/src/ApiResource/Book.php with Symfony or app/ApiResource/Book.php with Laravel
122+
namespace App\ApiResource;
120123
121124
use ApiPlatform\Metadata\GetCollection;
122125
use ApiPlatform\Metadata\ApiResource;
@@ -141,7 +144,8 @@ class Book
141144

142145
```yaml
143146
# api/config/api_platform/resources/Book.yaml
144-
App\Entity\Book:
147+
# The YAML syntax is only supported for Symfony
148+
App\ApiResource\Book:
145149
ApiPlatform\Metadata\GetCollection: ~
146150
get_desc_custom:
147151
class: ApiPlatform\Metadata\GetCollection

0 commit comments

Comments
 (0)