Error in laravel when recognizing the request of the route

0

Even after setting the route, when performing a post, the application occurs the "404 not foud" error. However, when accessing the index, I get data from my bank. Theoretically, it was also not to access.

I'll post the code for you to review

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.');
    }

}

Image of error when testing the API in postman

    
asked by anonymous 31.10.2017 / 19:01

2 answers

0

Man, Good afternoon, old the first thing to check is your route file, If you are using a correct api would you create your routes in api.php and not in web.php. NOTE: Remember that if you use the routes in api.php you have to access yourdomain / api / suarota

second as you are using the standard functions of laravel try the following

Route::resource('personal', 'PersonalController');

this way the standard laravel routes will accept the default request types.

    
31.10.2017 / 19:58
0

Try changing the order of the routes to

Route::post('/personal/new', 'PersonalController@store');

Route::get('/personal/remove/{id}', 'PersonalController@destroy');

Route::get('/personal', 'PersonalController@index');
    
26.07.2018 / 03:44