Hi there I have this problem with my update so here is my blade code:
<div class="form-group floating-label" id="role_colaboration1">
<select name="{{$role}}[]" id="role"
class="form- control">
<option value="2">Co-author</option>
<option value="3">Contributor</option>
<option value="4">Guest</option>
</select>
</div>
And here I have my ajax code
$(document).ready(function(){
$("#role").change(function(){
var role_value = $(this).val();
var bank_id =<?php echo json_encode($bank_id); ?>;
$.ajax({
method: "POST",
url: "{{ url('/banks/change-role-in-bank') }}",
data: {
_token: "{{ csrf_token() }}",
role_value: role_value,
bank_id: bank_id
},
success: function () {
$("select[id=role][value=" + role_value + "]");
},
error: function () {
console.log("error");
}
});
});
});
Here is my route:
Route::post('/change-role-in-bank', 'BankController@changeRoleInBank');
And here I have my controller:
public function changeRoleInBank(){
if(request()->ajax()) {
$bank_id = request()->input('bank_id');
$role = request()->input('role');
$bank_invites = BankInvite::select('id')->where('bank_id', $bank_id)->get();
$changeUserRole = BankInvitedUser::where('bank_invites_id', $bank_invites)->update(['role' => $role]);
return response()->json(Lang::get('general.bank_deleted'));
}
It is not updating What I am doing wrong..? is the ajax part