Passed
Push — task/user-api-endpoint ( f85fee...b47617 )
by Chris
09:12
created

User::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 App\Http\Resources\Applicant as ApplicantResource;
6
use App\Http\Resources\Manager as ManagerResource;
7
use Illuminate\Http\Resources\Json\JsonResource;
8
9
class User 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
            'applicant' => new ApplicantResource($this->whenLoaded('applicant')),
21
            'manager' => new ManagerResource($this->whenLoaded('manager')),
22
            'hr_advisor' => new JsonResource($this->whenLoaded('hr_advisor')),
23
        ]);
24
    }
25
}
26