StudentTransformer.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace App\Repositories\Transformers\School;
  3. use App\Repositories\Transformers\BaseTransformer;
  4. use Carbon\Carbon;
  5. /**
  6. * Class StudentTransformer.
  7. *
  8. * @package namespace App\Repositories\Transformers\School;
  9. */
  10. class StudentTransformer extends BaseTransformer
  11. {
  12. /**
  13. * Transform the Student entity.
  14. *
  15. * @param \App\Repositories\Models\School\Student $model
  16. *
  17. * @return array
  18. */
  19. public function lists($model)
  20. {
  21. return [
  22. 'id' => (int)$model->id,
  23. 'name' => $model->name,
  24. 'account' => $model->account,
  25. 'mobile' => $model->mobile,
  26. 'headimg' => $model->headimg,
  27. 'email' => $model->email,
  28. 'sex' => $model->sex,
  29. 'class' => $model->class,
  30. // 'intro' => $model->intro,
  31. 'is_register' => $model->is_register,
  32. 'admission_date' => $model->admission_date,
  33. 'year' => $model->year,
  34. 'status' => $model->status,
  35. 'created_at' => $model->created_at->format(Carbon::DEFAULT_TO_STRING_FORMAT),
  36. // 'updated_at' => $model->updated_at->format(Carbon::DEFAULT_TO_STRING_FORMAT)
  37. ];
  38. }
  39. public function detail($model)
  40. {
  41. return [
  42. 'id' => (int)$model->id,
  43. 'name' => $model->name,
  44. 'account' => $model->account,
  45. 'mobile' => $model->mobile,
  46. 'headimg' => $model->headimg,
  47. 'email' => $model->email,
  48. 'sex' => $model->sex,
  49. 'class' => $model->class,
  50. 'intro' => $model->intro,
  51. 'is_register' => $model->is_register,
  52. 'admission_date' => $model->admission_date,
  53. 'year' => $model->year,
  54. 'status' => $model->status,
  55. 'created_at' => $model->created_at->format(Carbon::DEFAULT_TO_STRING_FORMAT),
  56. 'updated_at' => $model->updated_at->format(Carbon::DEFAULT_TO_STRING_FORMAT)
  57. ];
  58. }
  59. }