I'm trying to create a route with an array of aliases, so when I call whois
or who_is
in the url it goes to the same route.
Then I don't need to keep repeating the code every time, changing only the alias.
I tried the code below.
Variables in the routes:
$path = 'App\Modules\Content\Controllers\ContentController@';
$aliases['whois'] = '(quemsomos|who_is|whois)';
Routes:
Route::get('{whois}', array('as' =>'whois', 'uses' => $path.'getWhois'))->where('whois', $aliases['whois']);
this one works as well
Route::get('{whois}', $path.'getWhois')->where('whois', $aliases['whois']);
Typing in the url my_laravel.com/whois
or my_laravel.com/who_is
or my_laravel.com/quemsomos
will send me to $path.'getWhois'
(which is correct).
But when I try to call it in the html on blade...
<a href="{{ route('whois') }}">Who we are</a>
The reference link goes to my_laravel.com//%7Bwhois%7D
How could I call route('whois')
on my blade.php and make it work like when I type it on the url ?
I would like to use the route
function` in my blade, so I can keep a pattern.