1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- namespace App\Repositories\Transformers\CMS;
- use App\Repositories\Enums\Base\BannerClickTypeEnum;
- use App\Repositories\Enums\Base\BannerPositionEnum;
- use Carbon\Carbon;
- use League\Fractal\TransformerAbstract;
- use App\Repositories\Models\CMS\Banner;
- /**
- * Class BannerTransformer.
- *
- * @package namespace App\Repositories\Transformers\CMS;
- */
- class BannerTransformer extends TransformerAbstract
- {
- /**
- * Transform the Banner entity.
- *
- * @param \App\Repositories\Models\CMS\Banner $model
- *
- * @return array
- */
- public function transform(Banner $model)
- {
- return [
- 'id' => (int)$model->id,
- 'name' => $model->name,
- 'position' => $model->position,
- 'position_name' => BannerPositionEnum::getDescription($model->position),
- 'click_type' => $model->click_type,
- 'click_type_text' => BannerClickTypeEnum::getDescription($model->click_type),
- 'click_body' => $model->click_body,
- 'cover' => $model->cover,
- 'cover_resource' => $model->cover_resource,
- 'start_time' => $model->start_time,
- 'end_time' => $model->end_time,
- 'sort' => $model->sort,
- 'status' => $model->status,
- 'created_at' => $model->created_at->format(Carbon::DEFAULT_TO_STRING_FORMAT),
- 'updated_at' => $model->updated_at->format(Carbon::DEFAULT_TO_STRING_FORMAT)
- ];
- }
- }
|