-
-
Save parzibyte/b3b496e945c58507b10fcddd003a77b5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Route::get("/usuario/{id}", function($id){ | |
return "Solamente respondo si el id tiene 1 o más dígitos numéricos"; | |
})->where("id", '[0-9]+'); | |
#Nota: el slug es el enlace amigable, por ejemplo: crud-de-mysql. Una ruta | |
# se vería así: articulo/2019/crud-de-mysql | |
Route::get("/articulo/{anio}/{slug}", function($anio, $slug){ | |
return "Quieres ver un artículo del año $anio con el slug $slug"; | |
})->where( | |
# Pasar un arreglo con las expresiones que deben cumplir | |
[ | |
"anio" => '[0-9]{4}', # Año de 4 dígitos exactos (no funcionará después del año 9999) | |
"slug" => '[A-Za-z0-9-_]+', # Conformado por letras mayúsculas o minúsculas, guiones bajos _ o normales - y números | |
] | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment