Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can I pass multiple routes as arguments to the Route::is() method in Laravel 8?

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

The goal

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 problem

The above method does not work.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Is there an alternative, working way to pass multiple routes as arguments?

>Solution :

You can do that as shown below

@if(request()->routeIs(['user','register','login']))
   Do something
@endif
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading