Passed
Push — task/batch-request-skills-step ( d5d8c8...80c6aa )
by Tristan
07:05 queued 02:01
created

Skill::toArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace App\Http\Resources;
4
5
use Illuminate\Http\Resources\Json\JsonResource;
6
use App\Models\SkillCategory;
7
8
class Skill extends JsonResource
9
{
10
    /**
11
     * Transform the resource into an array.
12
     *
13
     * @param  \Illuminate\Http\Request  $request
14
     * @return array
15
     */
16
    public function toArray($request)
17
    {
18
        $this->load('skill_categories');
19
        return array_merge(parent::toArray($request), [
20
            'skill_categories' => $this->skill_categories->pluck('id')->all()
21
        ]);
22
    }
23
}
24