VideoTransformer.php 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace App\Repositories\Transformers\Course;
  3. use App\Repositories\Enums\ModelStatusEnum;
  4. use App\Repositories\Transformers\BaseTransformer;
  5. use Carbon\Carbon;
  6. /**
  7. * Class CourseVideoTransformer.
  8. *
  9. * @package namespace App\Repositories\Transformers;
  10. */
  11. class VideoTransformer extends BaseTransformer
  12. {
  13. public function lists($model)
  14. {
  15. return [
  16. 'id' => (int)$model->id,
  17. 'title' => $model->title,
  18. 'slug' => $model->slug,
  19. // 'url' => $model->url,
  20. // 'url_resource' => $model->url_resource ?? '',
  21. 'view_num' => $model->view_num,
  22. // 'description' => $model->description,
  23. 'published_at' => $model->published_at,
  24. // 'course_chapter_id' => $model->course_chapter_id,
  25. 'course_chapter' => $model->course_chapter,
  26. 'duration' => $model->duration,
  27. // 'comment_status' => $model->comment_status,
  28. // 'subtitle_zh_path' => $model->subtitle_zh_path,
  29. // 'subtitle_zh_path_resource' => $model->subtitle_zh_path_resource ?? '',
  30. // 'subtitle_en_path' => $model->subtitle_en_path,
  31. // 'subtitle_en_path_resource' => $model->subtitle_en_path_resource ?? '',
  32. // 'ban_drag' => $model->ban_drag,
  33. 'sort' => $model->sort,
  34. 'status' => $model->status,
  35. // 'status_test' => ModelStatusEnum::getDescription($model->status),
  36. // 'created_at' => $model->created_at->format(Carbon::DEFAULT_TO_STRING_FORMAT),
  37. 'updated_at' => $model->updated_at->format(Carbon::DEFAULT_TO_STRING_FORMAT),
  38. 'humans' => $model->created_at->diffForHumans(),
  39. ];
  40. }
  41. /**
  42. * Transform the CourseVideo entity.
  43. *
  44. * @param \App\Repositories\Models\Course\Video $model
  45. *
  46. * @return array
  47. */
  48. public function detail($model)
  49. {
  50. return [
  51. 'id' => (int)$model->id,
  52. 'title' => $model->title,
  53. 'slug' => $model->slug,
  54. // 'url' => $model->url,
  55. 'url_resource' => $model->url_resource ?? '',
  56. 'view_num' => $model->view_num,
  57. // 'short_description' => $model->short_description,
  58. 'description' => $model->description,
  59. // 'published_at' => $model->published_at,
  60. // 'course_chapter_id' => $model->course_chapter_id,
  61. 'course_chapter' => $model->course_chapter,
  62. 'duration' => $model->duration,
  63. 'comment_status' => $model->comment_status,
  64. // 'subtitle_zh_path' => $model->subtitle_zh_path,
  65. 'subtitle_zh_path_resource' => $model->subtitle_zh_path_resource ?? '',
  66. // 'subtitle_en_path' => $model->subtitle_en_path,
  67. 'subtitle_en_path_resource' => $model->subtitle_en_path_resource ?? '',
  68. 'ban_drag' => $model->ban_drag,
  69. // 'sort' => $model->sort,
  70. 'status' => $model->status,
  71. 'status_test' => ModelStatusEnum::getDescription($model->status),
  72. // 'created_at' => $model->created_at->format(Carbon::DEFAULT_TO_STRING_FORMAT),
  73. 'updated_at' => $model->updated_at->format(Carbon::DEFAULT_TO_STRING_FORMAT),
  74. 'humans' => $model->created_at->diffForHumans(),
  75. ];
  76. }
  77. }