File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -195,6 +195,12 @@ class Book
195
195
{
196
196
public string $id;
197
197
public string $title;
198
+
199
+ public function __construct(string $id, string $title)
200
+ {
201
+ $this->id = $id;
202
+ $this->title = $title;
203
+ }
198
204
}
199
205
```
200
206
@@ -224,13 +230,14 @@ namespace App\State;
224
230
use ApiPlatform\Metadata\Operation;
225
231
use ApiPlatform\State\ProviderInterface;
226
232
use App\Models\Book as BookModel;
233
+ use App\ApiResource\Book;
227
234
228
235
final class BookProvider implements ProviderInterface
229
236
{
230
237
public function provide(Operation $operation, array $uriVariables = [], array $context = []): object|array|null
231
238
{
232
239
$book = BookModel::find($uriVariables['id']);
233
- return new BookModel (id: $book->id, title: $book->title);
240
+ return new Book (id: $book->id, title: $book->title);
234
241
}
235
242
}
236
243
```
You can’t perform that action at this time.
0 commit comments