0
Even after the route definition, when performing a post, the application occurs the error of "404 not foud". However, in this same, when accessing the index, I can obtain data from my database. Theoretically, it was also not to access.
I’ll post the code for you to analyze
Route::get('/personal', 'PersonalController@index');
Route::post('/personal/new', 'PersonalController@store');
Route::get('/personal/remove/{id}', 'PersonalController@destroy');
My controller:
public function store(PersonalRequest $request){
$this->validate($request, [
'cpf' => 'required|cpf',
]);
$user = new Personal;
$user->nome_pessoal = $request-> nome_pessoal;
$user->dt_nascimento = $request-> dt_nascimento;
$user->cidade = $request-> cidade;
$user->rg = $request-> rg;
$user->nome_pai = $request-> nome_pai;
$user->nome_mae = $request-> nome_mae;
$user->cpf = $request-> cpf;
$user->log_registro = date('Y-m-d H:i:s'); // salvando bd: ano/mes/dia
if(!$user) {
return error_log('');
} else {
$user->save();
return ('Page has been added.');
}
}
Screenshot of the error when testing the API in Postman
Which URL and which HTTP verb you are using to test in Postman?
– Jéf Bueno
http://127.0.0.1:8000/personal/new (doing a POST by Postman)
– Vinícius
Check the name of the file containing the controller
– Jéf Bueno
Make a GET to
127.0.0.1:8000/personal
works?– Jéf Bueno
Yes. I can access it.
– Vinícius
All routes are in the same file?
– Jéf Bueno
Yes. In web.php in the Routes folder
– Vinícius
What is the output of
php artisan route:list
?– Andreo Vieira
@Andreo Vieira http://prntscr.com/h4khoj
– Vinícius
Yes, but the route list did not list the routes /personal
– gmsantos