ChapterTransformer.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace App\Repositories\Transformers\Course;
  3. use Carbon\Carbon;
  4. use League\Fractal\TransformerAbstract;
  5. use App\Repositories\Models\Course\Chapter;
  6. /**
  7. * Class CourseChapterTransformer.
  8. *
  9. * @package namespace App\Repositories\Transformers;
  10. */
  11. class ChapterTransformer extends TransformerAbstract
  12. {
  13. /**
  14. * Transform the CourseChapter entity.
  15. *
  16. * @param \App\Repositories\Models\Course\Chapter $model
  17. *
  18. * @return array
  19. */
  20. public function transform($model)
  21. {
  22. return [
  23. 'id' => (int)$model->id,
  24. 'title' => $model->title,
  25. 'course' => $model->course,
  26. 'sort' => (int)$model->sort,
  27. 'humans' => $model->created_at->diffForHumans(),
  28. // 'status' => (int)$model->status,
  29. /* place your other model properties here */
  30. // 'created_at' => $model->created_at->format(Carbon::DEFAULT_TO_STRING_FORMAT),
  31. // 'updated_at' => $model->updated_at->format(Carbon::DEFAULT_TO_STRING_FORMAT)
  32. ];
  33. }
  34. }