Hey guys, all right?
I would really appreciate your help as I have been stuck with this problem for a couple of days and can not solve it myself.
I have a multi-line table with a checkbox on each line and a button that, when clicked, takes all the rows that are selected, stores the ids of those rows in an array, transforms the array into a json, and makes a request a route by passing this json, where it will be manipulated to go through all the ids and make changes to the database.
Initially it worked quietly, but for a while it stopped working, I do not know why.
JavaScript function (in the view):
function tornarPendente() {
var arrayIds = [];
//pega todos os checkbox que estão selecionados e para cada um pega o ID referente ao aluno
$.each($('.checkbox1').prop('checked', 'checked'), function() {
var id = ($(this).attr('id'));
arrayIds.push(id); //coloca no vetor de ids
});
//converte o array em um json para passar para a rota
var json = {
"ids": arrayIds
};
$.get('../controle/concluidas/tornarTodasPendentes', json, function(data) {
window.location.reload(true);
});
}
Route
Route::get('/controle/concluidas/tornarTodasPendentes/', function() {
$input = Input::only('ids'); //recebe um array de ids
$input = $input['ids'];
foreach($input as $id) {
$aluno = new App\Aluno();
$aluno = $aluno->where('id', '=', $id)->first();
$aluno->pendente = '1';
$aluno->save();
}
return Redirect::back();
});
NOTE: Strange is the fact that if I change the route address to a route that does not exist, javascript does not return any error (even if I remove the window.location.reaload (true) part) .
NOTE: If I give an alert (json ['ids']) I can see the ids normally.
Is there any way for me to know if these ids have at least reached the route?
Any kind of help is welcome.
Thank you!