ChapterTransformer.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace App\Http\Controllers\Wap\Book\Transformers;
  3. use App\Modules\Book\Services\ChapterCommentsService;
  4. use Hashids;
  5. class ChapterTransformer
  6. {
  7. public function transform($chapter){
  8. return [
  9. 'bid' => Hashids::encode($chapter->bid),
  10. //'bid_no_hash' => $chapter->bid,
  11. 'chapter_id' => $chapter->id,
  12. 'chapter_name' => $chapter->name,
  13. 'chapter_sequence' => $chapter->sequence,
  14. 'chapter_is_vip' => $chapter->is_vip,
  15. 'chapter_size' => $chapter->size,
  16. 'prev_cid' => $chapter->prev_cid,
  17. 'next_cid' => $chapter->next_cid,
  18. 'recent_update_at' => $chapter->recent_update_at,
  19. 'chapter_content' => $chapter->content,
  20. 'sign_status' => $chapter->sign_status,
  21. 'sign_reard' => isset($chapter->sign_reard)?$chapter->sign_reard:0,
  22. 'sign_days' => isset($chapter->sign_days)?$chapter->sign_days:0,
  23. 'is_show_subscribe_link' =>isset($chapter->is_show_subscribe_link)?$chapter->is_show_subscribe_link:0,
  24. 'is_had_subscribe'=>(isset($chapter->is_had_subscribe) && !empty($chapter->is_had_subscribe))?1:0,
  25. 'chapter_comment'=>isset($chapter->chapter_comment) ? $chapter->chapter_comment : '',
  26. 'next_jump'=>$chapter->next_jump,
  27. 'next_jump_url'=>$chapter->next_jump_url,
  28. 'show_push_title'=>$chapter->show_push_title,
  29. 'push_title_url'=>$chapter->push_title_url,
  30. 'push_title'=>$chapter->push_title,
  31. 'is_show_share_button'=>$chapter->is_show_share_button,
  32. 'share_url'=>isset($chapter->share_url)?$chapter->share_url:'',
  33. 'js_config'=>isset($chapter->js_config)?$chapter->js_config:'',
  34. 'is_show_ad'=>isset($chapter->is_show_ad)?$chapter->is_show_ad:'',
  35. 'is_visiable_ad'=>isset($chapter->is_visiable_ad)?$chapter->is_visiable_ad:0,
  36. //'is_had_subscribe'=>0
  37. //'is_need_subscirbe' => $chapter->is_need_subscirbe,
  38. ];
  39. }
  40. }