I am trying to deal with the routing in Laravel. How can I do the following?
If the user dials the number (3 to 11) here:
- /{numbers}
- /Area/{numbers}
- or /phone/{numbers}
The numbers may include a dash between them, as well as '1' at the beginning (this dialing code).
It is necessary to remove the dash then if the 11 numbers, need to remove '1' in beginning.
We redirect it depending on the number of digits dialed
- from 3 to 6 digits in the redirect / area /, with $ s1 = first 3 digits
- 6 to 10 are redirected to / phone /, with $ s1=first 3 digits, $s2= the following 3 digits
- 10 redirect in /phone/, with $s1=first 3 digits, $s2= the 3 following figures, $s3 = the 4 following numbers
My routes (While excluding a dash):
Route :: get ( 'area/{phone}', 'Controller@phone') -> where ([ 'phone' => '[0-9]{3,11}']);
Route :: get ( 'phone/{phone}', 'Controller@phone') -> where ([ 'phone' => '[0-9]{3,11}']);
The controller performs a dash removal, cropping unwanted numbers, cropping '1' if 11 digits and then redirect to /phone/, /area/.
But after the redirect, routes.php starts again and cycle becomes infinite.
What can I do? Maybe there is another way?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire