PaperTransformer.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace App\Repositories\Transformers\Exam;
  3. use App\Repositories\Transformers\BaseTransformer;
  4. use Carbon\Carbon;
  5. /**
  6. * Class PaperTransformer.
  7. *
  8. * @package namespace App\Repositories\Transformers\Exam;
  9. */
  10. class PaperTransformer extends BaseTransformer
  11. {
  12. /**
  13. * Transform the Paper entity.
  14. *
  15. * @param \App\Repositories\Models\Exam\Paper $model
  16. *
  17. * @return array
  18. */
  19. public function lists($model)
  20. {
  21. return [
  22. 'id' => (int)$model->id,
  23. 'title' => $model->title,
  24. 'category' => $model->category,
  25. 'slug' => $model->slug,
  26. 'course' => $model->course,
  27. 'video' => $model->video,
  28. 'approved_count' => $model->approved_count,
  29. 'submit_count' => $model->submit_count,
  30. 'published_at' => $model->published_at,
  31. 'mark' => $model->mark,
  32. 'topic_nums' => $model->topic_nums,
  33. 'time' => $model->time,
  34. 'status' => $model->status,
  35. 'user' => $model->user,
  36. 'exam_status' => $model->exam_status,
  37. 'updated_at' => $model->updated_at->format(Carbon::DEFAULT_TO_STRING_FORMAT),
  38. 'humans' => $model->created_at->diffForHumans(),
  39. ];
  40. }
  41. public function detail($model)
  42. {
  43. return [
  44. 'id' => (int)$model->id,
  45. 'title' => $model->title,
  46. 'category' => $model->category,
  47. 'slug' => $model->slug,
  48. 'course' => $model->course,
  49. 'body' => $model->body,
  50. 'video' => $model->video,
  51. 'user' => $model->user,
  52. 'time' => $model->time,
  53. 'approved_count' => $model->approved_count,
  54. 'submit_count' => $model->submit_count,
  55. 'published_at' => $model->published_at,
  56. 'mark' => $model->mark,
  57. 'topic_nums' => $model->topic_nums,
  58. 'topics_lists' => $model->topic_lists,
  59. 'status' => $model->status,
  60. 'updated_at' => $model->updated_at->format(Carbon::DEFAULT_TO_STRING_FORMAT),
  61. 'humans' => $model->created_at->diffForHumans(),
  62. ];
  63. }
  64. }