I have a problem with a form, and its route..
Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException
I have this:
{{ Form::model(array('route' => 'rrhh.cursos.store', 'method' => 'POST'), array('role' => 'form', 'id' => 'formulario')) }}
This is the route or action of the form.
Route::get('rrhh/empleados/{id}/cursos',array('uses'=>'CursosController@show', 'as' => 'rrhh.cursos.show'));
Route::post('rrhh/empleados/{id}/cursos/store',array('uses'=>'CursosController@store', 'as' => 'rrhh.cursos.store'));
I have these routes:
public function store($id)
{
// Creamos un nuevo objeto para nuestro nuevo usuario
$curso = new Curso;
// Obtenemos la data enviada por el usuario
$data = Input::all();
// Revisamos si la data es válido
if ($curso->isValid($data,false))
{
// Si la data es valida se la asignamos al usuario
$curso->fill($data);
// Guardamos el usuario
$curso->save();
// Y Devolvemos una redirección a la acción show para mostrar el usuario
return Redirect::route('rrhh.cursos.show', array($data->cedula));
}
else
{
// En caso de error regresa a la acción create con los datos y los errores encontrados
return Redirect::route('rrhh.cursos.show', array($data->cedula))->withInput()->withErrors($empleado->errors)->with('error_flag',true);
}
}
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
$empleado = Empleado::find($id);
$cursos = $empleado->cursos;
return View::make('rrhh/cursos/index_cursos')->with('cursos',$cursos)->with('id',$id);
}
When I press the register button, it makes the action of the form and it gives the error and when I inspect the code from Google Chrome, the action of the form gives another URL
form method="POST" action="http://localhost:8080/demosigal/public/rrhh/empleados/1/cursos" accept-charset="UTF-8" role="form" id="formulario"><input name="_token" type="hidden" value="2YSLitvrYvRSB6gYFHp7MAD4CXYKqwW2hg3aZZl6">
This must send me to rrhh.cursos.store
but it sends me to the same page where the form is. How do I resolve this problem?