Passed
Push — main ( 6b019d...208350 )
by Tan
07:07
created

ListPostResource::collection()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 1
c 1
b 1
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace CSlant\Blog\Api\Http\Resources;
4
5
use CSlant\Blog\Core\Facades\Base\Media\RvMedia;
6
use CSlant\Blog\Core\Http\Resources\Base\BaseListPostResource;
7
use CSlant\Blog\Core\Models\Post;
8
use Illuminate\Http\Request;
9
10
/**
11
 * @mixin Post
12
 */
13
class ListPostResource extends BaseListPostResource
14
{
15
    /**
16
     * @param  Request  $request
17
     *
18
     * @return array<string, mixed>
19
     */
20
    public function toArray($request): array
21
    {
22
        /** @var Post $this */
23
24
        return [
25
            'id' => $this->id,
26
            'name' => $this->name,
27
            'slug' => $this->slug,
28
            'description' => $this->description,
29
            'image' => $this->image ? RvMedia::url($this->image) : null,
30
            'categories' => CategoryResource::collection($this->categories),
31
            'tags' => TagResource::collection($this->tags),
32
            'author' => AuthorResource::make($this->author),
33
            'created_at' => $this->created_at,
34
            'updated_at' => $this->updated_at,
35
        ];
36
    }
37
}
38