我有一个编辑配置文件部分,我希望用户能够更新除密码之外的所有内容。我尝试删除控制器上的密码行,但它没有更新它只是显示与以前相同的数据。感谢任何帮助。
这是我的编辑控制器
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Request;
use App\User;
class UserController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
public function edit(User $user)
{
$user = Auth::user();
return view('users.edit', compact('user'));
}
public function update(Request $request,User $user)
{
$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,
'password' => 'required|string|min:8',
'country' => 'required|string|max:255',
'org_type' => 'required|string|max:255',
'depart' => 'required|string|max:255',
]);
$user->org_name = $request->get('org_name');
$user->email = $request->get('email');
$user->username = $request->get('username');
$user->password = bcrypt($request->get('password'));
$user->country = $request->get('country');
$user->org_type = $request->get('org_type');
$user->depart = $request->get('depart');
$user->save();
return back();
}
}
这是表格的一部分
<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>
慕仙森
呼啦一阵风