| @@ 20-41 (lines=22) @@ | ||
| 17 | * Class DocsSerializer |
|
| 18 | * @package App\GraphQL\Serializers |
|
| 19 | */ |
|
| 20 | class DocsPageSerializer extends AbstractSerializer |
|
| 21 | { |
|
| 22 | /** |
|
| 23 | * @param Model|DocsPage $page |
|
| 24 | * @return array |
|
| 25 | */ |
|
| 26 | public function toArray(Model $page): array |
|
| 27 | { |
|
| 28 | return [ |
|
| 29 | 'id' => $page->id, |
|
| 30 | 'title' => $page->title, |
|
| 31 | 'url' => route('docs.show', [ |
|
| 32 | 'version' => $page->docs->version, |
|
| 33 | 'slug' => $page->slug, |
|
| 34 | ]), |
|
| 35 | 'content' => $page->content_rendered, |
|
| 36 | 'content_source' => $page->content_source, |
|
| 37 | 'created_at' => $this->formatDateTime($page->created_at), |
|
| 38 | 'updated_at' => $this->formatDateTime($page->updated_at), |
|
| 39 | ]; |
|
| 40 | } |
|
| 41 | } |
|
| @@ 18-37 (lines=20) @@ | ||
| 15 | * Class DocsSerializer |
|
| 16 | * @package App\GraphQL\Serializers |
|
| 17 | */ |
|
| 18 | class DocsSerializer extends AbstractSerializer |
|
| 19 | { |
|
| 20 | /** |
|
| 21 | * @param Model|Docs $docs |
|
| 22 | * @return array |
|
| 23 | */ |
|
| 24 | public function toArray(Model $docs): array |
|
| 25 | { |
|
| 26 | return [ |
|
| 27 | 'id' => $docs->id, |
|
| 28 | 'title' => $docs->title, |
|
| 29 | 'image' => $docs->image, |
|
| 30 | 'version' => $docs->version, |
|
| 31 | 'description' => $docs->description, |
|
| 32 | 'created_at' => $this->formatDateTime($docs->created_at), |
|
| 33 | 'updated_at' => $this->formatDateTime($docs->updated_at), |
|
| 34 | 'pages' => DocsPageSerializer::collection($docs->pages) |
|
| 35 | ]; |
|
| 36 | } |
|
| 37 | } |
|