Skip to content

Commit

Permalink
Merge pull request #2036 from noweh/fix-laravel-docs
Browse files Browse the repository at this point in the history
* Update laravel/index.md file

- Added missing 'use' statements in the laravel/index.md for clarity
- Fixed a typo in a Model usage
- Corrected 'ProviderInterface::class' to 'provider' in ApiServiceProvider

* Update index.md

Change 'provider' to ProviderInterface::class in laravel/index.md

* Update laravel/index.md

Fix some docs about DTO

* Update laravel/index.md

Use the constructor property promotion syntax in ApiResource/Book

---------

Co-authored-by: Antoine Bluchet <soyuka@users.noreply.github.com>
  • Loading branch information
soyuka authored Dec 11, 2024
2 parents eb9bb47 + 9ab06c5 commit 2fd0a82
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions laravel/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,7 @@ use ApiPlatform\Metadata\Get;
#[Get(uriTemplate: '/my_custom_book/{id}')]
class Book
{
public string $id;
public string $title;
public function __construct(public string $id, public string $title) {}
}
```

Expand Down Expand Up @@ -224,6 +223,7 @@ namespace App\State;
use ApiPlatform\Metadata\Operation;
use ApiPlatform\State\ProviderInterface;
use App\Models\Book as BookModel;
use App\ApiResource\Book;

final class BookProvider implements ProviderInterface
{
Expand All @@ -242,8 +242,8 @@ Register the state provider:

namespace App\Providers;

use ApiPlatform\State\ProviderInterface;
use App\State\BookProvider;
use ApiPlatform\State\ProviderInterface;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Support\ServiceProvider;

Expand Down Expand Up @@ -273,8 +273,7 @@ use App\State\BookProvider;
#[Get(uriTemplate: '/my_custom_book/{id}', provider: BookProvider::class)]
class Book
{
public string $id;
public string $title;
public function __construct(public string $id, public string $title) {}
}
```

Expand Down Expand Up @@ -626,6 +625,7 @@ API Platform provides an easy shortcut to some [useful filters](./filters.md), f
namespace App\Models;

use ApiPlatform\Metadata\ApiResource;
+use ApiPlatform\Metadata\QueryParameter;
+use ApiPlatform\Laravel\Eloquent\Filter\PartialSearchFilter;
use Illuminate\Database\Eloquent\Model;

Expand All @@ -645,6 +645,7 @@ It's also possible to enable filters on every exposed property:
namespace App\Models;

use ApiPlatform\Metadata\ApiResource;
+use ApiPlatform\Metadata\QueryParameter;
+use ApiPlatform\Laravel\Eloquent\Filter\PartialSearchFilter;
+use ApiPlatform\Laravel\Eloquent\Filter\OrderFilter;
use Illuminate\Database\Eloquent\Model;
Expand Down

0 comments on commit 2fd0a82

Please sign in to comment.