throw new Methodnotallowedhttpexception($others); Laravel 5.7 Sending HTML form

Asked

Viewed 455 times

0

When creating the update in Laravel this giving the error.

protected function methodNotAllowed(array $others)
{
    throw new MethodNotAllowedHttpException($others);
}

View

{!! Form::model(array('route' => array('colaboradores.update', $colaboration->id), 'method' => 'put')) !!}
    <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', $colaboration->nome, ['class'=>'form-control'])!!}
            </div>
          </div>
      </div>
</div>

Controller

public function update(ColaborationFormRequest $request, $id)
{
    // Recupera todos os dados do formulário
    $dataForm = $request->all();

    //Recupera o colaborador para editar
    $colaboration = $this->colaboration->find($id);

    //Atualiza o colaborador
    $update = $colaboration->update($dataForm);

    //Verifica se editou o colaborador
    if ($update)
        return redirect()->route('colaboradores');
    else
        return redirect()->route('colaboradores.edit', $id)->with(['errors' => 'Falha ao editar']);
}

Route

Route::resource('/rh/colaboradores', 'RH\ColaborationController', [
'names' => [
    'index'     => 'colaboradores',
    'create'    => 'colaboradores.create',
    'edit'      => 'colaboradores.edit',
    'update'    => 'colaboradores.update',
]
]);

How do I solve?

1 answer

0


Browser other questions tagged

You are not signed in. Login or sign up in order to post.