UserController.php 836 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace App\Http\Controllers\Goodnight;
  3. use App\Http\Controllers\Controller;
  4. use App\Models\User\UserModel;
  5. use App\Services\Goodnight\UserService;
  6. class UserController extends Controller
  7. {
  8. /**
  9. * 获取某人用户信息
  10. * @param int $uid
  11. * @return array
  12. */
  13. public function getUser(int $uid): array
  14. {
  15. $user = UserModel::findOrfail($uid, ['uid', 'nickname', 'headimgurl', 'sex']);
  16. $uS = new UserService();
  17. $uS->getUser($user);
  18. unset($user->like_sex);
  19. unset($user->gnight_coin);
  20. unset($user->like_tone_1);
  21. unset($user->like_tone_2);
  22. unset($user->like_tone_3);
  23. unset($user->subscribed_at);
  24. return array(
  25. 'code' => 200,
  26. 'message' => 'success',
  27. 'data' => $user
  28. );
  29. }
  30. }