12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- namespace App\Repositories\Transformers\Course;
- use App\Repositories\Enums\ModelStatusEnum;
- use Carbon\Carbon;
- use League\Fractal\TransformerAbstract;
- use App\Repositories\Models\Course\Video;
- /**
- * Class CourseVideoTransformer.
- *
- * @package namespace App\Repositories\Transformers;
- */
- class VideoTransformer extends TransformerAbstract
- {
- /**
- * Transform the CourseVideo entity.
- *
- * @param \App\Repositories\Models\Course\Video $model
- *
- * @return array
- */
- public function transform(Video $model)
- {
- return [
- 'id' => (int)$model->id,
- 'title' => $model->title,
- 'slug' => $model->slug,
- 'url' => $model->url,
- 'url_resource' => $model->url_resource ?? '',
- 'view_num' => $model->view_num,
- 'short_description' => $model->short_description,
- 'description' => $model->description,
- 'published_at' => $model->published_at,
- 'course_chapter_id' => $model->course_chapter_id,
- 'course_chapter_name' => $model->course_chapter ? $model->course_chapter->title : '',
- 'duration' => $model->duration,
- 'comment_status' => $model->comment_status,
- 'subtitle_zh_path' => $model->subtitle_zh_path,
- 'subtitle_zh_path_resource' => $model->subtitle_zh_path_resource ?? '',
- 'subtitle_en_path' => $model->subtitle_en_path,
- 'subtitle_en_path_resource' => $model->subtitle_en_path_resource ?? '',
- 'ban_drag' => $model->ban_drag,
- 'sort' => $model->sort,
- 'status' => $model->status,
- 'status_test' => ModelStatusEnum::getDescription($model->status),
- 'created_at' => $model->created_at->format(Carbon::DEFAULT_TO_STRING_FORMAT),
- 'updated_at' => $model->updated_at->format(Carbon::DEFAULT_TO_STRING_FORMAT)
- ];
- }
- }
|