TransactionController.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. namespace App\Http\Controllers\Seller;
  3. use App\Http\Requests\SellerProfileRequest;
  4. use App\Models\User;
  5. use Auth;
  6. use Hash;
  7. class TransactionController extends Controller
  8. {
  9. /**
  10. * Display a listing of the resource.
  11. *
  12. * @return \Illuminate\Http\Response
  13. */
  14. public function index()
  15. {
  16. $user = Auth::user();
  17. return view('seller.transaction.index',compact('user'));
  18. }
  19. public function find()
  20. {
  21. }
  22. public function update()
  23. {
  24. $user = Auth::user();
  25. $userModel = User::findOrFail($user->id);
  26. if ($_POST["type"] == 1) {
  27. if ($user->tpwd) {
  28. flash(translate('You have set a trading password .'))->error();
  29. return back();
  30. }
  31. // 设置密码
  32. if (!$_POST["password"]) {
  33. flash(translate('password empty.'))->error();
  34. return back();
  35. }
  36. if (!$_POST["confirm_password"]) {
  37. flash(translate('confirm password empty.'))->error();
  38. return back();
  39. }
  40. if ($_POST["confirm_password"] != $_POST["password"]) {
  41. flash(translate('Password does not match.'))->error();
  42. return back();
  43. }
  44. $reg = "/^[0-9]{6}$/";
  45. $result = preg_match($reg, $_POST["password"]);
  46. if (!$result) {
  47. flash(translate('The transaction password is a six-digit pure number .'))->error();
  48. return back();
  49. }
  50. $pwd = md5($_POST["password"]);
  51. $userModel->tpwd = $pwd;
  52. $userModel->save();
  53. flash(translate('Your password has been updated successfully!'))->success();
  54. return back();
  55. } else {
  56. if (!$_POST["spwd"]) {
  57. flash(translate('original password empty.'))->error();
  58. return back();
  59. }
  60. if (md5($_POST["spwd"]) != $user->tpwd) {
  61. flash(translate('original password error.'))->error();
  62. return back();
  63. }
  64. // 设置密码
  65. if (!$_POST["password"]) {
  66. flash(translate('password empty.'))->error();
  67. return back();
  68. }
  69. if (!$_POST["confirm_password"]) {
  70. flash(translate('confirm password empty.'))->error();
  71. return back();
  72. }
  73. if ($_POST["confirm_password"] != $_POST["password"]) {
  74. flash(translate('Password does not match.'))->error();
  75. return back();
  76. }
  77. $reg = "/^[0-9]{6}$/";
  78. $result = preg_match($reg, $_POST["password"]);
  79. if (!$result) {
  80. flash(translate('The transaction password is a six-digit pure number .'))->error();
  81. return back();
  82. }
  83. $pwd = md5($_POST["password"]);
  84. $userModel->tpwd = $pwd;
  85. $userModel->save();
  86. flash(translate('Your password has been updated successfully!'))->success();
  87. return back();
  88. }
  89. }
  90. }