Request for a form with laravel not working

3

I am making a request from my controller for a form in the view, it is giving this error. I tried several methods but none solved.

Controller:

publicfunctionstore(Request$request){$NomeDaEmpresa=$request->input('NomeDaEmpresa');$nCompartilhamentos=$request->input('nCompartilhamentos');$valorPorShare=$request->input('valorPorShare');$eMail=$request->input('email');//Precoapagarsemataxa$PrecoaPagarST=$nCompartilhamentos*$valorPorShare;//Precoapagarcomataxa(20%)$PrecoaPagarTotal=$PrecoaPagarST*1.20;returnview('EnviarAnuncio');}}

Form:

<form role="form" action="/enviaranuncio" method="post">
                        <div class="form-group">
                            <label class="control-label" for="exampleInputEmail1">Nome da empresa</label>
                            <input class="form-control" id="exampleInputEmail1" placeholder="Digite o nome da empresa" type="text" value="" name="NomeDaEmpresa">
                        </div>
                        <div class="form-group">
                            <label class="control-label" for="exampleInputPassword1">Número de compartilhamento desejado</label>
                            <input class="form-control" id="exampleInputPassword1" placeholder="Número de shares" type="text" value="" name="nCompartilhamentos">
                        </div>
                        <div class="form-group">
                            <label class="control-label">Valor por share a pagar</label>
                            <input class="form-control" type="text" placeholder="Valor a pagar por share. Ex: 0.10" value="" name="valorPorShare">
                        </div>
                        <div class="form-group">
                            <label class="control-label">E-mail</label>
                            <input class="form-control" type="email" placeholder="Digite seu email" name="email" value="">
                        </div>
                        <button type="submit" class="btn btn-default">Criar Anúncio</button>
                    </form>
    
asked by anonymous 22.02.2017 / 19:06

2 answers

7

Whenever you set a form you have to pass the CSRF token to Laravel to be able to validate the request.

So, add the following after the <form> tag:

{{ csrf_field() }}

More info: link

    
22.02.2017 / 19:22
2

You can add the Collective HTML package [ link .

And replace <form> with {!! Form :: open () !!}, which already adds the input of _token.

    
22.02.2017 / 19:32