search function in Laravel returns TokenMismatchException error in VerifyCsrfToken.php

1

Good night friends, I am new to laravel and I need to build a function to search for data from a table, I did something based on what I understood so far, but it is returning me the following error message ** TokenMismatchException in VerifyCsrfToken. php line 67: ** when the route is requested. Here is the code below:

routes.php

Route::post('clientes/pesquisa', 'ClientesController@pesquisa');

CustomersController.php

public function pesquisa(){
        $pesq = Input::get('pesq');
        $resultado = Tb_clientes::where('idempresa', 1)->where('nome', '=',$pesq)->get();
        return view('clientes.index')->with('tb_clientes', $resultado);
    }

The route call location

<form class="form-inline" method="post" role="form" action="/clientes/pesquisa">
                          <div class="form-group">
                            <label >Pesquisar:</label>
                            <input type="text" class="form-control input-sm" id="pesq">
                          </div>
                          <button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-search"></button>
                        </form>

Am I doing it right or does it have an easier way?

    
asked by anonymous 15.07.2016 / 05:18

2 answers

1

Your first and most important step is to read as much of official documentation (if not the entire documentation), believe me, documentation is and always will be your best company.

Before performing a search you should learn how to build a new application from scratch, set the initial settings of your application, and configure your development environment. I can tell you that you will need to define and configure your database, your basic routes, your models, and then create, read, update and delete this data.

In relation to our community, I would like to welcome you and reinforce a part of the introduction text that reads as follows:

  

Focus your attention on questions about a real problem that you   faced. Include details about what you tried and exactly what you   you are trying to do.

Your question is very simple and incomplete, please let us know what you have tried and at which points you are most in difficulty. Do not forget to use the search up there to look for related questions and that might work for you too (try also our good old friend Google).

If at the end you're still having problems, try editing your question and adding more details.

I hope this has helped you in some way, I'll leave some interesting links that I found with a simple Google search related to Laravel.

And I could not stop telling you the Laracasts .

    
15.07.2016 / 05:49
1

This is a problem,

<input type="hidden" name="_token" value="{{ csrf_token() }}">

It worked!

    
16.07.2016 / 00:19