Completed
Push — master ( 2d22de...e2d103 )
by Sherif
02:14
created

AclUser::toArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 9.6666
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace App\Modules\Acl\Http\Resources;
4
5
use Illuminate\Http\Resources\Json\JsonResource;
6
use App\Modules\Acl\Http\Resources\AclGroup as AclGroupResource;
7
use App\Modules\Acl\Http\Resources\OauthClient as OauthClientResource;
8
use App\Modules\Notifications\Http\Resources\Notification as NotificationResource;
9
10
class AclUser extends JsonResource
11
{
12
    /**
13
     * Transform the resource into an array.
14
     *
15
     * @param  \Illuminate\Http\Request  $request
16
     * @return array
17
     */
18
    public function toArray($request)
19
    {
20
        return [
21
            'id' => $this->id,
22
            'name' => $this->name,
23
            'email' => $this->email,
24
            'profilePicture' => $this->profile_picture,
25
            'notifications' => NotificationResource::collection($this->whenLoaded('notifications')),
26
            'readNotifications' => NotificationResource::collection($this->whenLoaded('readNotifications')),
27
            'unreadNotifications' => NotificationResource::collection($this->whenLoaded('unreadNotifications')),
28
            'groups' => AclGroupResource::collection($this->whenLoaded('groups')),
29
            'oauthClients' => OauthClientResource::collection($this->whenLoaded('oauthClients')),
30
            'locale' => $this->locale,
31
            'timeZone' => $this->time_zone,
32
            'createdAt' => $this->created_at,
33
            'updatedAt' => $this->updated_at,
34
        ];
35
    }
36
}
37