I have a view in blade
, with a table, that through a method, loads me with a foreach
all the data of the database, which are requests, those requests have to be approved (changing the field of the database accepted, to 1) or denied, which would eliminate the request without more, my problem comes in that I am not able to pass the necessary parameters to the controller to update the request and disappear, I have tried different ways and I've seen many posts, but none of them exactly matches what I'm trying to do, here's the code:
Vista:
@if($vacations)
<table class="table table-striped table-bordered scrolling-dataTable">
<thead>
<tr>
<th>Nombre</th>
<th>Tipo</th>
<th>Fecha inicio</th>
<th>Fecha fin</th>
<th>Observaciones</th>
<th>Pendiente</th>
<th>Aprobar</th>
</tr>
</thead>
<tbody>
@foreach ($vacations as $vacation)
<tr>
<td>{{ $vacation->name }}</td>
<td>{{ $vacation->type }}</td>
<td>{{ $vacation->date_from }}</td>
<td>{{ $vacation->date_to }}</td>
<td>{{ $vacation->observations }}</td>
<td>{{ $vacation->aceptado }}</td>
<td> <!-- Single button definir boton para aprobar vacaciones -->
<div role="group" class="btn-group">
<button id="btnGroupDrop1" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="btn btn-outline-primary dropdown-toggle dropdown-menu-right"><i class="icon-cog3 icon-left"></i> Settings</button>
<div aria-labelledby="btnGroupDrop1" class="dropdown-menu">
<a href="{{ url ('/vacation/aceptado',[$vacation->id]) }}" class="dropdown-item">Aprobar</a>
<a href="{{url('/vacation/deny')}}" class="dropdown-item">Denegar</a></div>
</div>
</div>
</td>
</tr>
@endforeach
Driver:
public function update(Request $request, Vacation $vacations)
{
$this->validate($request, [
'aceptado' => 'required',
]);
//$inputs=Input::all();
//$vacation = new Vacation();
$vacation=Vacation::findOrFail($id);
$vacation-> aceptado = '1';
//$vacation-> id = $inputs['id'];
$vacation->save();
Mail::send("correo.solicitud", $data, function($message) use ($data){
$message->to('email','user')
->subject("Respuesta a su solicitud");
});
return redirect('/vacation/calendar');
}
and the route:
Route::post('/vacation/update', 'VacationController@update')->name('aceptado');
When I give the button to accept the request, it returns:
NotFoundHttpException in RouteCollection.php line 161: