I have a destroy method in my controller and I call it from a view to delete a record, but after confirming that I want to delete, the window remains blank and does not erase anything at all and does not redirect me to another view.
The driver code is this:
public function destroy($id)
{
Estudiante::findOrFail($id)->delete();
return redirect('estudiante');
}
And in the view I call it with the following code:
<a href='{{ route('estudiante.destroy',$estudiante->id)}}' onclick="return confirm('¿Esta seguro de eliminar este Estudiante?')" data-toggle="tooltip" data-placement="right" title="Eliminar">
<i class="fas fa-trash-alt" aria-hidden="true"></i>
</a>
Am I doing something wrong or something is missing?
------------ Fixed -------------
Some friends at the university gave me this solution and I want to share it with anyone who needs it.
It was just to create a new route in the web.php file
Route::get('estudiante/ocultar/{id}', 'EstudianteController@ocultar');
Then create a new function in the controller to which you are going to point the new route, and place what was in the destroy function.
public function ocultar($id)
{
Estudiante::findOrFail($id)->delete();
return redirect('estudiante');
}
And finally change the link in the following way:
<a href='{{ url('estudiante/ocultar',$estudiante->id)}}' onclick="return confirm('¿Esta seguro de eliminar este Estudiante?')" data-toggle="tooltip" data-placement="right" title="Eliminar">
<i class="fas fa-trash-alt" aria-hidden="true"></i>
</a>
Done all this works quietly, thank you very much everyone for the tips