Reputation: 4684
I am working on a Laravel 8 application. I need to use Route::is
for multiple routes, like this
@if(Route::is('user') or Route::is('register') or Route::is('login'))
Do something
@endif
I want to shorten this syntax so I tried to pass the routes as arguments to the Route::is()
method:
@if(Route::is('user,register,login'))
Do something
@endif
The above method does not work.
Upvotes: 5
Views: 930
Reputation: 1037
Even easier way:
@if(request()->routeIs('user','register','login'))
Do something
@endif
Upvotes: 1
Reputation: 186
You can do that as shown below
@if(request()->routeIs(['user','register','login']))
Do something
@endif
Upvotes: 7