我擁有來自數據庫的用戶詳細信息,並使用帶編輯按鈕的刀片環路進行打印。現在我想要的是,如果我點擊按鈕,我需要點擊用戶的按鈕的用戶詳細信息。Laravel用戶編輯
我試着隱藏輸入提交<input type="hidden" value="{{$user->email}}" name="email">
在我的控制器我只是打印表單提交值。但我只獲得最後一個用戶。
見下面,我希望你能明白..
<div class="content-wrapper">
<div class="flex-center position-ref full-height">
<form action="{!!url('/delete')!!}" method="post"> {!!csrf_field()!!}
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Email</th>
<th>Role</th>
</tr>
</thead>
<tbody>
@foreach($users as $user)
<tr>
<td>{{$user->id}}</td>
<td>{{$user->name}}</td>
<td>{{$user->email}}</td> <input type="hidden" value="{{$user->email}}" name="email">
<td>{{$user->role}}</td>
<td>
<div class="btn-group">
<button type="submit" class="btn btn-primary btn-sm" name="edit" >Edit</button>
<button type="submit" class="btn btn-primary btn-sm" name="delete" >Delete</button>
<button type="submit" class="btn btn-primary btn-sm" name="make" >Make Admin</button>
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</form>
</div>
</div>
把控制器代碼 –