Skip to content

Commit 2fd0a82

Browse files
authored
Merge pull request #2036 from noweh/fix-laravel-docs
* 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 <[email protected]>
2 parents eb9bb47 + 9ab06c5 commit 2fd0a82

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

laravel/index.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,7 @@ use ApiPlatform\Metadata\Get;
193193
#[Get(uriTemplate: '/my_custom_book/{id}')]
194194
class Book
195195
{
196-
public string $id;
197-
public string $title;
196+
public function __construct(public string $id, public string $title) {}
198197
}
199198
```
200199

@@ -224,6 +223,7 @@ namespace App\State;
224223
use ApiPlatform\Metadata\Operation;
225224
use ApiPlatform\State\ProviderInterface;
226225
use App\Models\Book as BookModel;
226+
use App\ApiResource\Book;
227227

228228
final class BookProvider implements ProviderInterface
229229
{
@@ -242,8 +242,8 @@ Register the state provider:
242242

243243
namespace App\Providers;
244244

245-
use ApiPlatform\State\ProviderInterface;
246245
use App\State\BookProvider;
246+
use ApiPlatform\State\ProviderInterface;
247247
use Illuminate\Contracts\Foundation\Application;
248248
use Illuminate\Support\ServiceProvider;
249249

@@ -273,8 +273,7 @@ use App\State\BookProvider;
273273
#[Get(uriTemplate: '/my_custom_book/{id}', provider: BookProvider::class)]
274274
class Book
275275
{
276-
public string $id;
277-
public string $title;
276+
public function __construct(public string $id, public string $title) {}
278277
}
279278
```
280279

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

628627
use ApiPlatform\Metadata\ApiResource;
628+
+use ApiPlatform\Metadata\QueryParameter;
629629
+use ApiPlatform\Laravel\Eloquent\Filter\PartialSearchFilter;
630630
use Illuminate\Database\Eloquent\Model;
631631

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

647647
use ApiPlatform\Metadata\ApiResource;
648+
+use ApiPlatform\Metadata\QueryParameter;
648649
+use ApiPlatform\Laravel\Eloquent\Filter\PartialSearchFilter;
649650
+use ApiPlatform\Laravel\Eloquent\Filter\OrderFilter;
650651
use Illuminate\Database\Eloquent\Model;

0 commit comments

Comments
 (0)