123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- namespace App\Repositories\Transformers\Course;
- use League\Fractal\TransformerAbstract;
- use App\Repositories\Models\Course\Comment;
- /**
- * Class CourseCommentTransformer.
- *
- * @package namespace App\Repositories\Transformers;
- */
- class CommentTransformer extends TransformerAbstract
- {
- /**
- * Transform the CourseComment entity.
- *
- * @param \App\Repositories\Models\Course\Comment $model
- *
- * @return array
- */
- public function transform(Comment $model)
- {
- if (isApiModule()) {
- return $this->apiTransform($model);
- }
- return [
- 'id' => (int)$model->id,
- 'content' => $model->content,
- 'course' => $model->course,
- 'user' => $model->user,
- 'course_video' => (int)$model->course_video,
- 'updated_at' => $model->updated_at->format('Y-m-d H:i:s'),
- ];
- }
- public function apiTransform(Comment $model)
- {
- return [
- 'id' => (int)$model->id,
- 'content' => $model->content,
- // 'course' => $model->course,
- 'user' => $model->user,
- 'course_video' => (int)$model->course_video,
- 'updated_at' => $model->updated_at->diffForHumans(),
- ];
- }
- }
|