<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

use App\Http\Resources\TypeResource;
use App\Http\Resources\NotificationResource;
class MemberResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
     
    public function toArray($request)
    {
        
       
        $data =  [
            'id' => $this->id,
           'name' => $this->name,
           'email'=>$this->email,
           'phone'=>$this->phone,
           'age'=>$this->age,
           'role'=>'member',
           'relative'=>$this->relative,
           'photo'=>asset('').$this->photo,
           'type'=>new TypeResource($this->whenLoaded('type')),
           'notifications'=>NotificationResource::collection($this->whenLoaded('notifications')),
            'current'=>ChannelResource::collection($this->whenLoaded('currents')),
            'pervious'=>ChannelResource::collection($this->whenLoaded('pervious')),
            
            
            
            
            
            
            
      ];
      return $data;
    }
}
