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
195195{
196196 public string $id;
197197 public string $title;
198+
199+ public function __construct(string $id, string $title)
200+ {
201+ $this->id = $id;
202+ $this->title = $title;
203+ }
198204}
199205```
200206
@@ -224,13 +230,14 @@ namespace App\State;
224230use ApiPlatform\Metadata\Operation;
225231use ApiPlatform\State\ProviderInterface;
226232use App\Models\Book as BookModel;
233+ use App\ApiResource\Book;
227234
228235final class BookProvider implements ProviderInterface
229236{
230237 public function provide(Operation $operation, array $uriVariables = [], array $context = []): object|array|null
231238 {
232239 $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);
234241 }
235242}
236243```
You can’t perform that action at this time.
0 commit comments