Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(default-order): compatibility with laravel #2072

Open
wants to merge 1 commit into
base: 4.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions core/default-order.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ customize this order, you must add an `order` attribute on your ApiResource anno

```php
<?php
// api/src/Entity/Book.php
namespace App\Entity;
// api/src/ApiResource/Book.php with Symfony or app/ApiResource/Book.php with Laravel
namespace App\ApiResource;

use ApiPlatform\Metadata\ApiResource;

Expand All @@ -30,7 +30,8 @@ class Book

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

```php
<?php
// api/src/Entity/Book.php
namespace App\Entity;
// api/src/ApiResource/Book.php with Symfony or app/ApiResource/Book.php with Laravel
namespace App\ApiResource;

use ApiPlatform\Metadata\ApiResource;

Expand All @@ -70,7 +71,8 @@ class Book

```yaml
# api/config/api_platform/resources/Book.yaml
App\Entity\Book:
# The YAML syntax is only supported for Symfony
App\ApiResource\Book:
order: ['foo', 'bar']
```

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

```php
<?php
// api/src/Entity/Book.php
namespace App\Entity;
// api/src/ApiResource/Book.php with Symfony or app/ApiResource/Book.php with Laravel
namespace App\ApiResource;

use ApiPlatform\Metadata\ApiResource;

Expand All @@ -103,7 +105,8 @@ class Book

```yaml
# api/config/api_platform/resources/Book.yaml
App\Entity\Book:
# The YAML syntax is only supported for Symfony
App\ApiResource\Book:
order: ['author.username']
```

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

```php
<?php
// api/src/Entity/Book.php
namespace App\Entity;
// api/src/ApiResource/Book.php with Symfony or app/ApiResource/Book.php with Laravel
namespace App\ApiResource;

use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\ApiResource;
Expand All @@ -141,7 +144,8 @@ class Book

```yaml
# api/config/api_platform/resources/Book.yaml
App\Entity\Book:
# The YAML syntax is only supported for Symfony
App\ApiResource\Book:
ApiPlatform\Metadata\GetCollection: ~
get_desc_custom:
class: ApiPlatform\Metadata\GetCollection
Expand Down