app/Http/Resources/UserResource.php
/**
     * Transform the resource into an array.
     *
     * @param  Request  $request
     * @return array
     */
Transform the resource into an array.
@param  Request  $request
@return array
Transform the resource into an array . @param Request $request @return array
public function toArray($request)
    {
        if (!isset($this->id))
            return null;
        return [
            'id' => $this->id,
            'name' => $this->name,
            'rank' => $this->rank,
            'isAdmin' => $this->hasRole('admin'),
            'avatar' => $this->profileImage ? env('IMAGE_PATH') . '/user_profile/xsmall_square/' . $this->profileImage->filename : null
        ];
    }
public function toArray ( $ request ) { if ( ! isset ( $ this -> id ) ) return null ; return [ 'id' => $ this -> id , 'name' => $ this -> name , 'rank' => $ this -> rank , 'isAdmin' => $ this -> hasRole ( 'admin' ) , 'avatar' => $ this -> profileImage ? env ( 'IMAGE_PATH' ) . '/user_profile/xsmall_square/' . $ this -> profileImage -> filename : null ] ; }
Transform the resource into an array.
Transform the resource into an array .