1
votes

I have a controller called "AgendaComplejoController". In this controller I have my index view. Ito my index.blade.php I have a form with a button(I made a form just to make a post request):

<form role="form" method="POST" action="{{ url('/guardarTurno') }}">
    {{ csrf_field() }}
    <button type="submit" class="btn btn-labeled btn-success button-infousuario">
   <span class="btn-label"><i class="fa fa-check fa-fw"></i></span>
       Confirmar turno
   </button>
</form>

I want to call a function into my Agendacontroller

public function guardarTurno(Request $request)
    {
        Log::info('entré al guardar turnos');   
    Log::info('json: '.json_encode($request));  
    }

My route is:

Route::get('/guardarTurno', 'AgendaComplejoController@guardarTurno');

I have the following error:

MethodNotAllowedHttpException

But I can't connect my blade view with my controller method.

What I'm doing wrong?

1
You're trying to POST to a get route. Change your route from get to post.aynber

1 Answers

1
votes

In your router, you're registering the route as a get.

Route::get('/guardarTurno', 'AgendaComplejoController@guardarTurno');

And your form, your submitting as a post.

<form role="form" method="POST" action="{{ url('/guardarTurno') }}">

So change your method to a post:

Route::post('/guardarTurno', 'AgendaComplejoController@guardarTurno');