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 just give me this message here:
Symfony \ Component \ HttpKernel \ Exception \
MethodNotAllowedHttpException
No message
And via get works
In the VerifyCsrfToken.php file
I left it 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,
],
What is not to get the token because I could not send the client out of laravel