PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, April 19, 2022

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

 April 19, 2022     laravel, laravel-8, laravel-blade, php     No comments   

Issue

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.

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


Answered By - Donnicias
Answer Checked By - Senaida (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing