I want to update a record from the background_check_batches
table. What was done is listing all the records and each has a status
property (column) that can be changed. Clicking on the status
value will prompt a popup modal to update the value. Since there are multiple records sharing one model, the form's action is changed using js. The issue here is when submitting the form, requested data is received but the BackgroundCheckBatch
model id is not. I have previously done this kind of task which is identical but it just doesn't work for some reason. Below are my codes.
web.php
Route::put('/admin/dashboard/background-request/{backgroundrequest}', 'BackgroundCheckBatchController@update')->name('update');
status.blade.php ()
{!! Form::open(['action' => ['BackgroundCheckBatchController@update', -1], 'method' => 'POST', 'id' => 'adminBackgroundCheckStatusModalForm']) !!}
@csrf
@method("PUT")
<div class="modal__content">
<select class="table_custom_select" id="Status" name="status">
<option class="table_custom_select_pending" value="Pending">Pending</option>
<option class="table_custom_select_progress" value="In Progress">In Progress</option>
<option class="table_custom_select_complete" value="Completed">Completed</option>
</select>
</div>
<div class="modal__footer">
<button type="submit" class="button button_size_m button_theme_primary">Proceed</button>
</div>
{!! Form::close() !!}
BackgroundcheckBatchController
public function update(Request $request, BackgroundCheckBatch $backgroundCheckBatch) {
return $backgroundCheckBatch;
}
return $backgroundCheckBatch;
outputted and empty array, []
I expect it to return the BackgroundCheckBatch
of the provided id in the URL
If I return $request;
, it will output like so:
{
_token: "Ax789Dr4VXFVE1vpjtKhEWdBjdCZqARDaNQnk7K8",
_method: "PUT",
status: "Completed"
}
Do inform me if I'm not providing enough detail
You're using implicit binding, but it doesn't work because your route parameter doesn't match argument name of your controller's method,
Change your route's parameter to snake_case of $backgroundCheckBatch
(type-hinted argument name of controller's method):
Route::put('/admin/dashboard/background-request/{background_check_batch}', 'BackgroundCheckBatchController@update')->name('update');