123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?php
- namespace App\Repositories\Transformers\User;
- use App\Repositories\Enums\SexEnum;
- use App\Repositories\Models\User\User;
- use Carbon\Carbon;
- use League\Fractal\TransformerAbstract;
- /**
- * Class StudentTransformer.
- *
- * @package namespace App\Repositories\Transformers\User;
- */
- class UserTransformer extends TransformerAbstract
- {
- /**
- * Transform the Student entity.
- *
- * @param \App\Repositories\Models\User\User $model
- *
- * @return array
- */
- public function transform(User $model)
- {
- return [
- 'id' => (int)$model->id,
- 'username' => $model->username,
- 'turename' => $model->turename,
- 'name' => $model->name,
- 'faculty' => $model->faculty,
- 'class' => $model->class,
- 'headimg' => $model->headimg,
- 'period' => $model->period,
- 'sex' => $model->sex,
- 'sex_text' => SexEnum::getDescription($model->sex),
- 'mobile' => $model->mobile,
- 'created_at' => $model->created_at->format(Carbon::DEFAULT_TO_STRING_FORMAT),
- 'updated_at' => $model->updated_at->format(Carbon::DEFAULT_TO_STRING_FORMAT)
- ];
- }
- }
|