Passed
Push — main ( 18250b...f71c86 )
by Tan
02:53 queued 25s
created

ListCategoryResource::toArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 12
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace CSlant\Blog\Api\Http\Resources;
4
5
use CSlant\Blog\Core\Http\Resources\Base\BaseListCategoryResource;
6
use CSlant\Blog\Core\Models\Category;
7
use Illuminate\Http\Request;
8
9
/**
10
 * @mixin Category
11
 */
12
class ListCategoryResource extends BaseListCategoryResource
13
{
14
    /**
15
     * @param  Request  $request
16
     *
17
     * @return array<string, mixed>
18
     */
19
    public function toArray($request): array
20
    {
21
        /** @var Category $this */
22
23
        return [
24
            'id' => $this->id,
25
            'name' => $this->name,
26
            'slug' => $this->slug,
27
            'icon' => $this->icon,
28
            'description' => $this->description,
29
            'children' => CategoryResource::collection($this->children),
30
            'parent' => new CategoryResource($this->parent),
31
        ];
32
    }
33
}
34