4

I would like to add a css class condionally in my blade body tag by adding auth-container class if url is either /login or /auth/reset-password

so i have

<body> //here add class

So i have tried

@if(in_array(  , ['login','/auth/reset-password']) )//stuck here
   <body class="auth-container">
@else()
    <body> //no class
@endif()

Am stuck on how to figure out if the url is /login or /auth/reset-password hence add the class auth-container

1
  • what laravel version are you using? are your routes named? Commented Oct 2, 2017 at 19:03

1 Answer 1

5

The is method in your request can check if the url is matching a pattern. You may use the * character as a wildcard:

<body @if(Request::is('login/*') || Request::is('auth/reset-password')) class="auth-container" @endif>
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks this works if i may also ask which one can i use to negate the above is there not to replace is
to negate, just the ! so !Request::is('login/') for example

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.