i am trying to come up with a specific url structure in my laravel 8  to catch all the route i use catch-all route at the end of the web.php & then to get the single character token and the ID we manipulate the string provided 
is there any other way to do it  
Route::get('{any}', function($any = null){
    // Break up the url into seperate parts.
    $pieces = explode("-", $any);
    $pieces = array_reverse($pieces);
    $piece =  $pieces[0];
    // Remove the .html
    $piece = substr($piece, 0, -5);
    // Get the two parts of the identifier.
    $id = substr($piece, 1);
    $token = substr($piece, 0, 1);
    // Call correct controller based on the token.
    switch ($token) {
        case "d":
            // HERE I WANT TO PASS THE ID ON TO THE SHOW ACTION OF THE DIRECTORY CONTROLLER 
        break;
        case "p":
            // HERE I WANT TO PASS THE ID ON TO THE SHOW ACTION OF THE POSTS CONTROLLER 
        break;
        default:
            return abort(404);
        break;
    }
});