4
I am trying to pass an update parameter, but it is giving error.
Controller
public function update(ColaborationFormRequest $request, $id
{
$dataForm = $request->all();
$colaboration = $this->colaboration->find($id);
$update = $colaboration->update($dataForm);
if ($update)
return redirect()->route('colaboradores.index');
else
return redirect()->route('colaboradores.edit', $id)
->with(['errors' => 'Falha ao editar']);
}
Route
Route::resource('/colaboradores', 'RH\ColaborationController', [
'names' => [
'index' => 'colaboradores',
'create' => 'colaboradores.create',
'edit' => 'colaboradores.edit',
'update' => 'colaboradores.update',
]]);
View
{!! Form::open(['route' => 'colaboradores.update']) !!}
<fieldset>
<div class="card">
<h5 class="card-header dark"><i class="fas fa-user"></i> Dados pessoais</h5>
<div class="card-body">
<div class="row">
<div class="form-group col-md-6">
{{ Form::label('nome', 'Nome: ') }}
{{ Form::text('nome', null, ['class'=>'form-control'])}}
</div>
</div>
What error appears ? So without knowing which error appears to you help is a bit blind :) If you have the $id entering by the function your route should be /collaborators/{id} and not just /collaborators. However, if you are receiving a POST, why don’t you send the id around ?
– Ricardo Santos
Yeah, it’s true, anyway, I’m pretty sure that tip I give solves the problem.
– Ricardo Santos
Sorry. I edited the call form and it worked
– Aguinaldo Tupy