<?php

namespace App\Http\Controllers\Wap\Book\Transformers;
use App\Modules\Book\Services\ChapterCommentsService;
use Hashids;
class ChapterTransformer
{
    public function transform($chapter){
        return [
            'bid'       =>  Hashids::encode($chapter->bid),
            //'bid_no_hash'       =>  $chapter->bid,
            'chapter_id'       =>  $chapter->id,
            'chapter_name'   =>  $chapter->name,
            'chapter_sequence'   =>  $chapter->sequence,
            'chapter_is_vip'   =>  $chapter->is_vip,
            'chapter_size'   =>  $chapter->size,
            'prev_cid'   =>  $chapter->prev_cid,
            'next_cid'   =>  $chapter->next_cid,
            'recent_update_at'   =>  $chapter->recent_update_at,
            'chapter_content'   =>  $chapter->content,
            'sign_status'   =>  $chapter->sign_status,
            'sign_reard'   =>  isset($chapter->sign_reard)?$chapter->sign_reard:0,
            'sign_days'   =>  isset($chapter->sign_days)?$chapter->sign_days:0,
            'is_show_subscribe_link' =>isset($chapter->is_show_subscribe_link)?$chapter->is_show_subscribe_link:0,
            'is_had_subscribe'=>(isset($chapter->is_had_subscribe) && !empty($chapter->is_had_subscribe))?1:0,
            'chapter_comment'=>isset($chapter->chapter_comment) ? $chapter->chapter_comment : '',
            'next_jump'=>$chapter->next_jump,
            'next_jump_url'=>$chapter->next_jump_url,
            'show_push_title'=>$chapter->show_push_title,
            'push_title_url'=>$chapter->push_title_url,
            'push_title'=>$chapter->push_title,
            'is_show_share_button'=>$chapter->is_show_share_button,
            'share_url'=>isset($chapter->share_url)?$chapter->share_url:'',
            'js_config'=>isset($chapter->js_config)?$chapter->js_config:'',
            'is_show_ad'=>isset($chapter->is_show_ad)?$chapter->is_show_ad:'',
            //'is_had_subscribe'=>0
            //'is_need_subscirbe'   =>  $chapter->is_need_subscirbe,
        ];
    }
}