AttachTransformer.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace App\Repositories\Transformers\Course;
  3. use App\Repositories\Models\Course\Attach;
  4. use Carbon\Carbon;
  5. use League\Fractal\TransformerAbstract;
  6. /**
  7. * Class CourseAttachTransformer.
  8. *
  9. * @package namespace App\Repositories\Transformers;
  10. */
  11. class AttachTransformer extends TransformerAbstract
  12. {
  13. /**
  14. * Transform the CourseAttach entity.
  15. *
  16. * @param \App\Repositories\Models\Course\Attach $model
  17. *
  18. * @return array
  19. */
  20. public function transform(Attach $model)
  21. {
  22. return [
  23. 'id' => (int)$model->id,
  24. 'course_id' => (int)$model->course_id,
  25. 'course_video_id' => (int)$model->course_video_id,
  26. 'course_video_name' => $model->course_video ? $model->course_video->title : '',
  27. 'name' => $model->name,
  28. 'path' => $model->path,
  29. 'path_resource' => $model->path_resource,
  30. 'sort' => (int)$model->sort,
  31. 'status' => (int)$model->status,
  32. 'created_at' => $model->created_at->format(Carbon::DEFAULT_TO_STRING_FORMAT),
  33. 'updated_at' => $model->updated_at->format(Carbon::DEFAULT_TO_STRING_FORMAT)
  34. ];
  35. }
  36. }