2
I have the following method
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Validator;
use App\Pessoa;
class PessoaController extends Controller
{
public function lista( Request $request ){
$nome = "%".$request->input( 'nome' )."%";
$telefone = "%".$request->input( 'telefone' )."%";
$empresa = $request->input( 'empresa' );
$setor = $request->input( 'setor' );
$cargo = $request->input( 'cargo' );
$email = "%".$request->input( 'email' )."%";
$pessoa = Pessoa::with(['empresa', 'setor','cargo'])
->where( [
[ 'nm_pessoa', 'like', $nome],
[ 'telefone', 'like', $telefone ],
[ 'email', 'like', $email ],
[ 'cd_empresa', 'like', $empresa ],
[ 'cd_setor', 'like', $setor ],
[ 'cd_cargo', 'like', $cargo ]
] )
->get();
return response()->json( $pessoa );
}
}
I have the following route
Route::group(['prefix' => 'api'], function(){
Route::group(['prefix' => 'pessoa'], function (){
Route::get( '', 'PessoaController@lista' );
Route::post( 'add', ['as' => 'add', 'uses' => 'PessoaController@add'] );
});
});
I would like to send data via post, but only that gives this message here:
Symfony Component Httpkernel Exception \
Methodnotallowedhttpexception
No message
And via get it works
In the Verifycsrftoken.php file
I left like this
protected $except = [
'api/pessoa/*'
];
}
And in Kernel.php
protected $middlewareGroups = [
'web' => [
// \App\Http\Middleware\EncryptCookies::class,
// \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
// \Illuminate\Session\Middleware\StartSession::class,
// \Illuminate\Session\Middleware\AuthenticateSession::class,
// \Illuminate\View\Middleware\ShareErrorsFromSession::class,
// \App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
Which is not to get the token because I could not send from the customer outside the Standard
The problem is the bar in front of the link, remove to test and warns.
http://localhost/controle/api/pessoa
– David Dias
What bar? I don’t understand
– adventistaam
In the POST call, in Postman. You put a bar at the end of the link. Remove it.
– David Dias
That’s right. It worked. Thank you very much
– adventistaam