CpSubTransformer.php 2.0 KB

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