I have a very simple method, that the only thing that it does is take the id from a form, to erase the insertion, the issue is that it does not work for me:
Vista: I have a form, in which you select the id of the vacation and I pass it to the method
<form action="{{url('vacation/delete')}}" method="POST" role="form">
{{csrf_field()}}
<legend>Solicitudes Pendientes</legend>
<select name= "vacation_id" id="inputVacation_id" class = "form-control" required="required">
@foreach ($vacations as $vacation)
<option >{{$vacation->name}}</option>
@endforeach
</select>
<button type="submit" name="delete" class= "btn btn-primary"><i class="icon-cross2"></i></i></button>
</form>
Then in the controller:
public function delete(Request $request){
//$vac = Vacation::find($request['vacation_id']);
//$res=Vacation::where('id',$vac)->delete();
Vacation::destroy($request['vacation_id']);
return redirect()->back();
}
public function delSolicitudes()
{
$vacations = \DB::table('vacations')
->select('workers.name','vacations.id' ,'vacations.type','vacations.date_from','vacations.date_to','vacations.observations','vacations.aceptado')
->join('workers','workers.id','=','vacations.worker_id')
->where(['vacations.aceptado' => '0'])
->get();
return view('vacation.deletevac', ['vacations' => $vacations]);
}
You can see that I simply have the query to get the data, that I really do not need any more than the id, but when I give it to delete it does not erase anything, it does not give an error, but it does not do anything either,
Question 2: Comment that I have tried to use the same form, which I use to update with the delete, and it has not worked for me, would it be possible to update and delete in the same form? whereas you have to falsify the methods?
Greetings and thanks.