123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- namespace App\Repositories\Transformers\Course;
- use Carbon\Carbon;
- use League\Fractal\TransformerAbstract;
- use App\Repositories\Models\Course\Chapter;
- /**
- * Class CourseChapterTransformer.
- *
- * @package namespace App\Repositories\Transformers;
- */
- class ChapterTransformer extends TransformerAbstract
- {
- /**
- * Transform the CourseChapter entity.
- *
- * @param \App\Repositories\Models\Course\Chapter $model
- *
- * @return array
- */
- public function transform(Chapter $model)
- {
- return [
- 'id' => (int)$model->id,
- 'title' => $model->title,
- 'course_id' => (int)$model->course_id,
- 'course_name' => $model->course ? $model->course->title : '',
- 'sort' => (int)$model->sort,
- 'status' => (int)$model->status,
- /* place your other model properties here */
- 'created_at' => $model->created_at->format(Carbon::DEFAULT_TO_STRING_FORMAT),
- 'updated_at' => $model->updated_at->format(Carbon::DEFAULT_TO_STRING_FORMAT)
- ];
- }
- }
|