123456789101112131415161718192021222324252627282930 |
- <?php
- namespace Knuckles\Scribe\Tests\Fixtures;
- use Illuminate\Http\Resources\Json\JsonResource;
- class TestPostApiResource extends JsonResource
- {
- /**
- * Transform the resource into an array.
- *
- * @param \Illuminate\Http\Request $request
- *
- * @return array
- */
- public function toArray($request)
- {
- return [
- 'id' => $this->id,
- 'title' => $this->title ,
- 'body' => $this->body,
- 'tags' => $this->whenLoaded('tags', function () {
- return TestTagApiResource::collection($this->tags);
- }),
- 'image' => $this->whenLoaded('image', function () {
- return TestImageApiResource::make($this->image);
- }),
- ];
- }
- }
|