123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- namespace App\Repositories\Transformers\Course;
- use Carbon\Carbon;
- 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)
- {
- return [
- 'id' => (int)$model->id,
- 'content' => $model->content,
- 'course_id' => (int)$model->course_id,
- // 'course_name' => $model->course->title ?? '',
- 'user_id' => (int)$model->user_id,
- 'user' => $model->user()->get(['name', 'headimg']),
- 'course_video_id' => (int)$model->course_video_id,
- // 'course_video_name' =>$model->course_video->title,
- 'points' => (int)$model->points,
- 'created_at' => $model->created_at->diffForHumans(),
- // 'updated_at' => $model->updated_at->format(Carbon::DEFAULT_TO_STRING_FORMAT)
- ];
- }
- }
|