I have this error in my web application:
The POST method is not supported for this route. Supported methods: GET, HEAD, PUT, PATCH, DELETE.
but i don´t understand where are my problem because, my route:list comand return this:
| | GET|HEAD | calendario | calendario.index | App\Http\Controllers\EventController@index | web |
| | POST | calendario | calendario.store | App\Http\Controllers\EventController@store | web |
| | GET|HEAD | calendario/create | calendario.create | App\Http\Controllers\EventController@create | web |
| | GET|HEAD | calendario/{calendario} | calendario.show | App\Http\Controllers\EventController@show | web |
| | PUT|PATCH | calendario/{calendario} | calendario.update | App\Http\Controllers\EventController@update | web |
| | DELETE | calendario/{calendario} | calendario.destroy | App\Http\Controllers\EventController@destroy | web |
| | GET|HEAD | calendario/{calendario}/edit | calendario.edit | App\Http\Controllers\EventController@edit | web |
i want to create event in my full calendar using a route::resource.
my route:
Route::resource('calendario', 'EventController');
and in my view i have a check for to know in that route i´m if edit, store or show:
<form action="{{ Request::is('calendario/*/edit') ? route('calendario.update', $event->id) : route('calendario.create') }}" method="POST">
{{ csrf_field() }}
@if(Route::currentRouteName() == 'calendario.edit')
@method('PUT')
@endif
in my web browser console i have a correct route:
<form action="http://www.clinicacampoy.local/calendario/create" method="POST">
<input type="hidden" name="_token" value="rVb2ycSugwg0weAbZucdI8RzBi9uT7QumGArJOOW">
<div class="form-group">
<label for="nombre">Nombre</label>
<input type="text" class="form-control" name="nombre" id="nombre" value="" aria-describedby="emailHelp" placeholder="Nombre del cliente">
</div>
<div class="form-group">
<label for="fecha-inicio">Fecha-hora Inicio</label>
<input type="text" value="" class="form-control" name="fecha_inicio" id="fecha-inicio">
</div>
<div class="form-group">
<label for="fecha-inicio">Fecha-hora fin</label>
<input type="text" value="" class="form-control" name="fecha_fin" id="fecha-fin">
</div>
<input type="submit" class="btn btn-info" value="Crear Cita">
</form>
but return this error and i don´t know that i´m doin wrong. In my controler for this moment i have a echo
for to know that i´m arrive
you should use store
instead of create
in route('calendario.create')
.
create
method is a get method that is responsible for making creating view. the storage logic should be in store method.
If you want to use Route::resource
though.