Powiadomienia
Wyczyść wszystko
BugOverflow
1
Wpisy
1
Użytkownicy
0
Reactions
901
Widoki
0
27/07/2021 7:13 pm
Rozpoczynający temat
how to detect currently selected controller? (blade template)
1 odpowiedź
0
27/07/2021 7:16 pm
Rozpoczynający temat
- Create helper
- app/helpers.app
- register it inside composer.json
"autoload": { "psr-4": { "App\\": "app/", "Database\\Factories\\": "database/factories/", "Database\\Seeders\\": "database/seeders/" }, "files": [ "app/helpers.php" ] },
- Inside helpers.php
function isMenuItemSelected($url) { if (url()->current() == $url) return 'active'; return; }
-
how to detect currently active menu item
<a href="{{route('forms.index')}}" class="list-group-item list-group-item-action py-2 ripple {{isMenuItemSelected(route('forms.index'))}}" >