Files
pingan_unionpay_new/app/Merchant/Controllers/Setting/IndexController.php
2021-01-31 11:50:56 +08:00

56 lines
1.8 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace App\Merchant\Controllers\Setting;
use App\Merchant\Controllers\Controller;
use Auth;
use Illuminate\Http\Request;
use Validator;
class IndexController extends Controller
{
/**
* 修改密码
* @param Request $request 数据集
* @return [type] [description]
*/
public function password(Request $request)
{
$user = Auth::guard('merchant')->user();
if ($request->isMethod('post')) {
$validator = Validator::make($request->all(), [
'password' => 'required|confirmed',
'password_confirmation' => 'required',
], [
'password.required' => '新密码必须填写',
'password_confirmation.required' => '确认密码必须填写',
'password.confirmed' => '两次密码不一致',
]);
if ($validator->fails()) {
return $this->error($validator->errors()->first());
}
$user->password = $request->password;
$res = $user->save();
if ($res === true) {
return $this->success('修改成功');
} else {
return $this->error('修改失败');
}
} else {
return view('Merchant::setting.password');
}
}
}