, как сказано в заголовке, когда я go пользователям / 1 показывает форму, после того, как я что-то изменяю и нажимаю подтвердить, что она не обновляется, ни в представлении, ни в базе данных. В чем здесь проблема?
мой взгляд edit.blade. php
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header"><h2 style="text-align:center;">Edit Your Profile</h2></div>
<div class="card-body">
<form method="post" action="{{route('users.update',$user)}}">
{{ csrf_field() }}
{{ method_field('patch') }}
<div class="form-group row">
<label for="org_name" class="col-md-4 col-form-label text-md-right">{{ __('Organisation Name ') }}</label>
<div class="col-md-6">
<input id="org_name" name="org_name" type="text" class="form-control"value="{{$user->org_name}}">
@error('org_name')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control" name="email" value="{{ $user->email }}">
@error('email')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="username" class="col-md-4 col-form-label text-md-right">{{ __('Username') }}</label>
<div class="col-md-6">
<input id="username" type="username" class="form-control" name="username" value="{{ $user->username }}">
@error('username')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<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>
<div class="form-group row">
<label for="country" class="col-md-4 col-form-label text-md-right">{{ __('Country') }}</label>
<div class="col-md-6">
<input id="country" type="text" class="form-control" name="country" value="{{$user->country}}">
@error('country')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="org_type" class="col-md-4 col-form-label text-md-right">{{ __('Organisation Type') }}</label>
<div class="col-md-6">
<input id="org_type" type="text" class="form-control" name="org_type" placeholder="Vet/Uni" value="{{$user->org_type}}" >
@error('org_type')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="depart" class="col-md-4 col-form-label text-md-right">{{ __('Department') }}</label>
<div class="col-md-6">
<input id="depart" type="text" class="form-control" name="depart" value="{{ $user->depart}}">
@error('depart')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row mb-0">
<div class="col-md-6 offset-md-4">
<button type="submit" class="btn btn-primary">
Edit
</button>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
мой UserController
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(User $user)
{
$this->validate(request(), [
'org_name' => ['required', 'string', 'max:255','unique:users'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'username' => ['required', 'string','max:255', 'unique:users'],
'password' => ['required', 'string', 'min:8', 'confirmed'],
'country' => ['required', 'string', 'max:255'],
'org_type' => ['required', 'string', 'max:255'],
'depart' => ['required', 'string', 'max:255'],
]);
$user->org_name = request('org_name');
$user->email = request('email');
$user->username = request('username');
$user->password = bcrypt(request('password'));
$user->country = request('country');
$user->org_type = request('org_type');
$user->depart = request('depart');
$user->save();
return back();
}
}
мои маршруты
Route::get('users/{user}', ['as' => 'users.edit', 'uses' => 'UserController@edit']);
Route::patch('users/{user}/update', ['as' => 'users.update', 'uses' => 'UserController@update']);
Заранее спасибо! Я думаю, что-то не так с пользователями / 1 / update route?