BookTransformer.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * Date: 2017/3/31
  5. * Time: 14:02
  6. */
  7. namespace App\Http\Controllers\KuaiYingYong\Book\Transformers;
  8. use Hashids;
  9. class BookTransformer
  10. {
  11. public function transform($book){
  12. return [
  13. 'book_id'=>Hashids::encode($book->bid),
  14. //'book_id_no_hash'=>$book->bid,
  15. 'book_name'=>$book->book_name,
  16. 'book_summary'=>$book->intro,
  17. 'book_author'=>$book->author,
  18. 'cover_url'=>$book->cover,
  19. 'book_word_count'=>$book->size,
  20. 'book_chapter_total'=>$book->chapter_count,
  21. 'book_category_id'=>$book->category_id,
  22. 'book_category'=>$book->category_name,
  23. 'book_end_status'=>$book->status,
  24. 'book_published_time'=>is_null($book->updated_at)?'':$book->updated_at,
  25. 'copyright'=>is_null($book->copyright)? '':$book->copyright,
  26. 'charge_type'=>is_null($book->charge_type)?'':$book->charge_type,
  27. 'force_subscribe_chapter_id'=>$book->force_subscribe_chapter_seq,
  28. 'update_time'=>$book->updated_at,
  29. 'is_on_shelf'=>$book->is_on_shelf,
  30. 'book_price'=>is_null($book->price)?0:$book->price,
  31. 'keyword'=>$book->keyword,
  32. 'recommend_index'=> $book->recommend_index,
  33. 'is_show_index_content'=>$book->is_show_index_content,
  34. 'click_count'=>$book->click_count,
  35. 'product_id'=>$book->product_id,
  36. 'sex_preference'=>$book->channel_name,
  37. 'last_cid'=>$book->last_cid,
  38. 'last_chapter'=>$book->last_chapter,
  39. 'first_cid'=>$book->first_cid,
  40. 'is_on_user_shelf'=>$book->is_on_user_shelf,
  41. 'last_chapter_is_vip'=>$book->last_chapter_is_vip
  42. ];
  43. }
  44. }