StudentResource.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace App\Http\Resources;
  3. use App\Models\Area;
  4. use App\Models\User;
  5. use Illuminate\Http\Resources\Json\JsonResource;
  6. class StudentResource extends JsonResource
  7. {
  8. /**
  9. * Transform the resource into an array.
  10. *
  11. * @param \Illuminate\Http\Request $request
  12. * @return array
  13. */
  14. public function toArray($request)
  15. {
  16. $model = $this->resource;
  17. // $data = [
  18. // 'id' => $model->id,
  19. // 'nickname' => $model->user->nickname,
  20. // 'realName' => $model->user->truename,
  21. // 'avatar' => $model->user->avatar,
  22. // 'mobile' => $model->user->mobile,
  23. // 'idCard' => $model->user->idCard,
  24. // 'is_card_certified' => $model->user->is_card_certified,
  25. // 'register_area_id' => $model->user->register_area_id,
  26. // 'name' => $model->name,
  27. // 'type' => $model->type,
  28. // 'student_no' => $model->student_no,
  29. // 'year' => $model->year,
  30. // 'imgs' => $model->imgs,
  31. // 'auth_status' => $model->auth_status,
  32. // 'error_msg' => $model->error_msg,
  33. // 'admin_id' => $model->admin_id,
  34. // 'status' => $model->status,
  35. // 'created_at' => $model->created_at,
  36. // 'updated_at' => $model->updated_at
  37. // ];
  38. $data = [
  39. ];
  40. return array_merge(parent::toArray($request), $data);
  41. }
  42. }