2 回答
TA贡献1827条经验 获得超7个赞
问题是,如果您没有发送密码,您将返回视图。
您需要在控制器上删除这些行:
$user->password = bcrypt($request->get('password'));
并删除:
'password' => 'required|string|min:8',
来自$this->validate($request,
然后更新您的视图,使其不发送密码:
<div class="form-group row">
<label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>
<div class="col-md-6">
<input id="password" type="password" class="form-control" name="password" >
@error('password')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="password-confirm" class="col-md-4 col-form-label text-md-right">{{ __('Confirm Password') }}</label>
<div class="col-md-6">
<input id="password-confirm" type="password" class="form-control" name="password_confirmation" required autocomplete="new-password">
</div>
</div>
这将起作用。
TA贡献1802条经验 获得超6个赞
尝试这个:
public function update(Request $request)
{
$userId = auth()->user()->id;
$this->validate($request, [
'org_name' => 'required|string|max:255|unique:users,org_name,'.$user->id,
'email' => 'required|string|email|max:255|unique:users,email,'.$user->id,
'username' => 'required|string|max:255|unique:users,username,'.$user->id,
'country' => 'required|string|max:255',
'org_type' => 'required|string|max:255',
'depart' => 'required|string|max:255',
]);
$user = User::find($userId);
$user->org_name = $request->get('org_name');
$user->email = $request->get('email');
$user->username = $request->get('username');
$user->country = $request->get('country');
$user->org_type = $request->get('org_type');
$user->depart = $request->get('depart');
$user->save();
return back();
}
}
- 2 回答
- 0 关注
- 83 浏览
添加回答
举报