<?php
/**
 * Created by PhpStorm.
 * Date: 2017/3/31
 * Time: 14:02
 */

namespace App\Http\Controllers\Wap\Book\Transformers;

use Hashids;

class BookGiftsTransformer
{
    public function transform($gift){
        return [
            'bid'=>Hashids::encode($gift->bid),
            'gift_name'=>$gift->name_desc,
            'cost'=>$gift->cost,
            'icon'=>$gift->icon,
            'gift_id'=>$gift->gift_id,
            'send_time'=>$gift->created_at->format('Y-m-d H:i:s'),
            'user_nickname'=>empty($gift->nickname)?$gift->uid:$gift->nickname,
            'book_name'=>isset($gift->book_name)?$gift->book_name:''
        ];
    }
}