AccountDetail.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. /**
  3. *------Create thems Model------
  4. *------SCWPHP Version 1.0.0------
  5. *------Dev Model Jions------
  6. *------Create Time 2017-06-12 05:08:18------
  7. */
  8. namespace App\Api\Model;
  9. use \System\Model;
  10. use Biz\Account\AccountManager;
  11. class AccountDetail extends Model {
  12. protected $table = 'account_detailed';
  13. /**
  14. * 修改用户基本信息
  15. *
  16. * @access public
  17. * @return String
  18. */
  19. public function updateUserInfo()
  20. {
  21. // 获取用户信息
  22. $accountManagerClass = new AccountManager;
  23. $userInfo = $accountManagerClass -> getCurrentUser();
  24. if (empty($userInfo['identity'])) {
  25. Render([], '2001', lang('Common','Api') -> get('user does login'));
  26. }
  27. $updateWhere['account_identity'] = $userInfo['identity'];
  28. $updateData = [];
  29. // 提取修改数据
  30. if (!empty($_POST['email'])) {
  31. $updateData['email'] = $_POST['email'];
  32. }
  33. if (!empty($_POST['phone'])) {
  34. $updateData['phone'] = $_POST['phone'];
  35. }
  36. if (!empty($_POST['img_id'])) {
  37. $updateData['img_id'] = $_POST['img_id'];
  38. $updateData['img_url'] = '';
  39. }
  40. if (!empty($_POST['name'])) {
  41. $updateData['name'] = $_POST['name'];
  42. }
  43. if (empty($updateData)) {
  44. Render([], '4027', lang('Common','Api') -> get('please enter the modification'));
  45. }
  46. return lm('Account_detailed', 'commons') -> updateDetailed($updateWhere, $updateData);
  47. }
  48. /**
  49. * 上传用户基本信息头像
  50. *
  51. * @access public
  52. * @return String
  53. */
  54. public function updateHeader()
  55. {
  56. // 获取用户信息
  57. $accountManagerClass = new AccountManager;
  58. $userInfo = $accountManagerClass -> getCurrentUser();
  59. if (empty($userInfo['identity'])) {
  60. Render([], '2001', lang('Common','Api') -> get('user does login'));
  61. }
  62. $updateWhere['account_identity'] = $userInfo['identity'];
  63. $avatar = $request->file('avatar')->store('/public/' . date('Y-m-d') . '/avatars');
  64. echo json_encode($input);die;
  65. $updateData = [];
  66. // 提取修改数据
  67. if (!empty($_POST['email'])) {
  68. $updateData['email'] = $_POST['email'];
  69. }
  70. if (!empty($_POST['phone'])) {
  71. $updateData['phone'] = $_POST['phone'];
  72. }
  73. if (!empty($_POST['img_id'])) {
  74. $updateData['img_id'] = $_POST['img_id'];
  75. $updateData['img_url'] = '';
  76. }
  77. if (!empty($_POST['name'])) {
  78. $updateData['name'] = $_POST['name'];
  79. }
  80. if (empty($updateData)) {
  81. Render([], '4027', lang('Common','Api') -> get('please enter the modification'));
  82. }
  83. return lm('Account_detailed', 'commons') -> updateDetailed($updateWhere, $updateData);
  84. }
  85. }