I have a menu with 3 possibilities: pg1, pg2 or pg3. The page is generated in Blade using bootstrap.
<a href="#" class="active">pg1</a>
<a href="#">pg2</a>
<a href="#">pg3</a>
I would have to identify in which route we are to activate the correct menu.
Doing some research on the internet I found this answer that could solve my problem: Inside the view ...
<a href="#" {{{ (Request::is('pg1') ? 'class=active' : '')>pg1</a>
<a href="#" {{{ (Request::is('pg2') ? 'class=active' : '')>pg2</a>
<a href="#" {{{ (Request::is('pg3') ? 'class=active' : '')>pg3</a>
That is, the route that requested the page would be identified and the active class would be loaded accordingly.
But this answer does not help me because:
So:
Route::group(['prefix'=>'{account}'], function (){
Route::get('/pg1', function ($account) {
return view('pg1');//pg1 do usuario
});
Route::get('/pg3', function ($account) {
return view('pg3');//pg2 do usuario
});
Route::get('/pg3', function ($account) {
return view('pg3');//pg3 do usuario
});
});
If you have 2 users paulo and beto.
We would have the following possible routes
paulo/pg1,
paulo/pg2,
paulo/pg3,
beto/pg1,
beto/pg2,
beto/pg3,
That is, it would always fail the route verification test to generate the active link <a href="#" {{{ (Request::is('pg1') ? 'class=active' : '')>pg1</a>
.
The only solution I see right now would be to run a REGEX test to check for pg1 or pg2 or pg3.
What would be another approach to avoiding this REGEX test?