Passed
Push — task/application-profile-react... ( 95a834...f06e77 )
by Yonathan
08:39
created

Skill::toArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 6
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
use Illuminate\Support\Facades\Log;
8
9
class Skill extends JsonResource
10
{
11
    /**
12
     * Transform the resource into an array.
13
     *
14
     * @param  \Illuminate\Http\Request  $request
15
     * @return array
16
     */
17
    public function toArray($request)
18
    {
19
        return array_merge(parent::toArray($request), [
20
            'skill_category_ids' => $this->when(
21
                $this->relationLoaded('skill_categories'),
22
                $this->skill_categories->pluck('id')->all()
23
            )
24
        ]);
25
    }
26
}
27