我正在创建一个网站。我已经创建了一个注册页面。我想更新我的详细信息。当我单击 AdminPanel.blade.php 中的 Edit 按钮时,它会提供 AdminUpdate.blade.php 中的所有详细信息。更改数据后,当我单击“更新用户”按钮时,出现此错误。- " 抱歉,找不到您要找的页面。"
我怎样才能解决这个问题 ??
这是我的 AdminPanel.blade.php
<table class="table table-bordered">
<tr>
<td> Name </td>
</tr>
@foreach($data as $value )
<tr>
<td> {{ $value->username }} </td>
<td> <a href="edit/{{ $value->id }}"><input type="submit" name="update" value="Update" class="btn-primary"></a> </td>
</tr>
@endforeach
</table>
这是我的 AdminPanelController.php
public function edit($id)
{
$edd = User::find($id);
//dd($edd);
return view('AdminUpdate', ['edd' => $edd]);
}
public function adminedit($id, Request $request)
{
// Add Validation
$users = User::find($id);
$users->username = $request->get('username');
$users->email = $request->get('email');
$users->save();
return redirect('AdminPanel');
}
这是我的 AdminUpdate.blade.php
<form action="adminedit/{{ $edd->id }}" method="post" enctype="multipart/form-data">
{{ method_field('PUT') }}
{{ csrf_field() }}
<div class="form-group">
<label>Username : *</label>
<input type="text" class="form-control" name="username" value="{{$edd->username}}" placeholder="Enter Your Username" required>
</div>
<div class="form-group">
<label>Email : *</label>
<input type="email" class="form-control" name="email" value="{{$edd->email}}" placeholder="Enter Your Username" required>
</div>
<div class="form-group">
<label>Password : *</label>
<input type="password" class="form-control" name="password" value="{{$edd->password}}" placeholder="Enter Your Password" required>
</div>
<div class="form-group">
<label>Upload Profile Picture :</label>
<input type="file" class="form-control-file" name="file_img" aria-describedby="fileHelp">
<small id="fileHelp" class="form-text text-muted">If U Want , U Can Skip Upload A Profile Picture</small>
</div>
<input type="submit" class="btn btn-primary" value="Update User">
</form>
这是我的路线。
Route::get('/edit/{id}', 'AdminPanelController@edit');
Route::put('/adminedit/{id}', 'AdminPanelController@adminedit');
更新到@Alex
<form action="/adminedit/2" method="post" enctype="multipart/form-data">
<input type="hidden" name="_method" value="PUT">
<input type="hidden" name="_token" value="eECno3BdT86XYW2PfLjxL4ABtekEBLbxFvDmxY9y">
<div class="form-group">
<label>Username : *</label>
<input type="text" class="form-control" name="username" value="head_slsoc_1" placeholder="Enter Your Username" required>
</div>
<div class="form-group">
<label>Email : *</label>
<input type="email" class="form-control" name="email" value="[email protected]" placeholder="Enter Your Username" required>
</div>
<div class="form-group">
<label>Password : *</label>
<input type="password" class="form-control" name="password" value="asd" placeholder="Enter Your Password" required>
</div>
<div class="form-group">
<label>Upload Profile Picture :</label>
<input type="file" class="form-control-file" name="file_img" aria-describedby="fileHelp">
<small id="fileHelp" class="form-text text-muted">If U Want , U Can Skip Upload A Profile Picture</small>
</div>
<input type="submit" class="btn btn-primary" value="Update User">
</form>
由于您使用的是PUT
方法:
{{ method_field('PUT') }}
将路线改为:
Route::put('/adminedit/{id}', 'AdminPanelController@adminedit');
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句