<?php
/**
 * Created by PhpStorm.
 * User: hp
 * Date: 2017/12/2
 * Time: 16:52
 */

namespace App\Http\Controllers\Manage\User\Transformers;

class UserTransformer
{
    public function transform($userItem)
    {
        return [
            'id' => $userItem->id,
            'nickname' => $userItem->nickname,
            'openid' => $userItem->openid,
            'unionid' => $userItem->unionid,
            'distribution_channel_id' => $userItem->distribution_channel_id,
            'encrypted_distribution_channel_id' => encodeDistributionChannelId($userItem->distribution_channel_id),
            'province' => $userItem->province,
            'city' => $userItem->city,
            'country' => $userItem->country,
            'headimgurl' => $userItem->head_img,
            'send_order_id' => $userItem->send_order_id,
            'balance' => $userItem->balance,
            'register_time' =>date("Y-m-d H:i:s",strtotime($userItem->created_at)),
            'update_time' =>date("Y-m-d H:i:s",strtotime($userItem->updated_at)),
            'year_order_start_time'=>isset($userItem->begin_time)?$userItem->begin_time:'',
            'year_order_end_time'=>isset($userItem->end_time)?$userItem->end_time:''
        ];
    }
}