I have a jQuery DataTable in a Laravel App. I want to confirm the previously stored data from someone else by using a checkbox. When that checkbox is checked I want to update that record's attribute is_confirmed
with the value 1 (true). Now I can get all the records that i need to confirm from the database. However when I try to confirm one of them, every single record is confirmed even why i leave the other checkbox unchecked.
I guess that the error is in the controller update method below:
public function update(Request $request)
{
$user = Auth::user();
$is_validated = $request->get('is_validated');
foreach ($is_validated as $valid_Id) {
if($valid_Id.value(1)) //<-here i suspect that the error is
{
DB::table('reports')->update(['is_validated' => 1, 'validated_by' => $user->id]);
}
}
return view('validate.update');
}
I tried changing the value of the checkbox with the code below.
$('.checkbox').change(function(){
cb = $(this);
cb.val(cb.prop('checked'));
cb.value = 1;
});
And I also tried using radio buttons, however since they all have the same name i could only select 1 button in all the records.
I'm stuck at this point and it seems that I can't figure it out on my own. All the help or hints are appreciated.
Aucun commentaire:
Enregistrer un commentaire