У меня есть таблица, в которой я хочу обновить таблицу дополнительными данными ... но она обновляет только 1 запись, даже когда я выбираю другой столбец. Пожалуйста, помогите спасибо.
// The call to the modal
<a href="#custom-modal" class="btn btn-primary btn-md waves-effect waves-light"
data-animation="fadein" data-id="{{$value->id}}" data-plugin="custommodal" data-overlaySpeed="200" data-overlayColor="#36404a">
<i class="glyphicon glyphicon-refresh "></i> Update
</a>
// method on modal
<form role="form" data-parsley-validate novalidate method="POST" action="{{url('hr/updateRecord/'. $value->id)}}">
// My controller function
public function updateStaff(Request $request)
{
$staff = User::find($request->id);
$staff->salary = $request->salary;
$staff->phone = $request->phone;
$staff->age = $request->age;
$staff->startDate = $request->date;
$staff->office = $request->office;
$staff->save();
Session::flash('message','Successfully Updated '.$request->firstname.'s record');
return redirect('hr/staffdetails');
}
// route
Route::post('/updateRecord/{id}','HrController@updateStaff');
еслия пытаюсь обновить запись веревки, например ... это данные Наны, которые будут обновлены, и это единственная запись, которая будет обновлена независимо от имени, которое я выберу
// блейд для таблицы
<div class="bottom-table">
<div class="table table-responsive">
<table class="table table-striped table-bordered" id="table">
<thead>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Position</th>
{{-- <th>Department</th> --}}
<th>Phone number</th>
<th>Office</th>
<th>Age</th>
<th>Start Date</th>
<th>Salary</th>
<th><center>Action</center></th>
</tr>
</thead>
{{ csrf_field() }}
<tbody>
@foreach($staff as $value)
<tr>
<td>{{$value->firstname}}</td>
<td>{{$value->lastname}}</td>
<td>{{$value->position}}</td>
{{-- <td>{{$value->department_id}}</td> --}}
<td>{{$value->phone}}</td>
<td>{{$value->office}}</td>
<td>{{$value->age}}</td>
<td>{{$value->startDate}}</td>
<td>N{{$value->salary}}</td>
<td><center>
<a href="#custom-modal" class="btn btn-primary btn-md waves-effect waves-light"
data-animation="fadein" data-id="{{$value->id}}" data-plugin="custommodal" data-overlaySpeed="200" data-overlayColor="#36404a">
<i class="glyphicon glyphicon-refresh "></i> Update
</a>
<a href="attendance.html" class="show-modal btn btn-info btn-sm" data-id="{{$value->id}}">
<i class="glyphicon glyphicon-time"></i> Attendance
</a>
</center>
</td>
</tr>
@endforeach
</tbody>
</table>
// Модал для обновления
<div id="custom-modal" class="modal-demo">
<button type="button" class="close" onclick="Custombox.close();">
<span>×</span><span class="sr-only">Close</span>
</button>
<h4 class="custom-modal-title">Update staff report</h4>
<div class="custom-modal-text text-left">
<form role="form" data-parsley-validate novalidate method="POST" action="{{url('hr/updateRecord/'.$value->id)}}">
<input type="hidden" name="_token" value="{{csrf_token()}}"/>
<div class="form-group">
<label for="name">Age</label>
<input type="number" class="form-control" id="name" name="age" required parsley-trigger="change">
</div>
<div class="form-group">
<label for="name">Phone number </label>
<input type="number" class="form-control" id="phone" name="phone" required parsley-trigger="change">
</div>
<div class="form-group">
<label for="name">Office</label>
<input type="text" class="form-control" id="office" name="office" required parsley-trigger="change">
</div>
<div class="form-group">
<label for="name">Salary </label>
<input type="number" class="form-control" id="salary" name="salary" placeholder="" required parsley-trigger="change">
</div>
<div class="form-group">
<label for="assign">Start date</label>
<input type="text" class="form-control" name="date" id="datepicker" placeholder="format yyyy-mm-dd" required parsley-trigger="change">
</div>
<button type="submit" class="btn btn-success waves-effect waves-light">Save</button>
<button type="button" class="btn btn-danger waves-effect waves-light m-l-5">Cancel</button>
</form>
</div>