<?php

use Pecee\SimpleRouter\SimpleRouter as Route;
use Pecee\Http\Request;
use Pecee\SimpleRouter\Exceptions\NotFoundHttpException;

Route::group(['prefix' => '/api'], function() {
    Route::get('/secret', function() {
        return 'API Secret';
    });

    Route::post('login', 'AuthController@login');
    Route::post('register', 'AuthController@register');
    Route::post('logout', 'AuthController@logout');

    Route::get('parking', 'ParkingController@getAll');
    Route::get('parking/{id}', 'ParkingController@get');
    Route::post('parking/status', 'ParkingController@rentSpace');
});

Route::error(function(Request $request, \Exception $exception) {
    if($exception instanceof NotFoundHttpException && $exception->getCode() === 404) {
        response()->redirect('/api/secret');
    }
});
<?php

use Pecee\SimpleRouter\SimpleRouter as Route;
use Pecee\Http\Request;
use Pecee\SimpleRouter\Exceptions\NotFoundHttpException;

Route::group(['prefix' => '/api'], function() {
    Route::get('/secret', function() {
        return 'API Secret';
    });

    Route::post('login', 'AuthController@login');
    Route::post('register', 'AuthController@register');
    Route::post('logout', 'AuthController@logout');

    Route::get('parking', 'ParkingController@getAll');
    Route::get('parking/{id}', 'ParkingController@get')
        ->setMatch('/\/parking\/([0-9]+)/');
});

Route::error(function(Request $request, \Exception $exception) {
    if($exception instanceof NotFoundHttpException && $exception->getCode() === 404) {
        response()->redirect('/api/secret');
    }
});
Add route param constraint to get parking space
Add route param constraint to get parking space
