I am a new user to Laravel and have came from craft cms. On my homepage I want the navigation to be transparent and have a black background on all other pages. 

To do this I have added a class to the homepage header called header-home. I craft to add this class to the homepage inside the layout file I wrote this:

```
<header {% if craft.request.lastSegment == "" %}class="header-home"   {% endif %}>

```

I know I could just create a different layout.blade.php file for the homepage but there will be other instances when I want to add a class or an element depending on what page or url the user is on.

Thanks in advance,
Jamie
['https://Stackoverflow.com/questions/53963876', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3479267/']
You can send the class from controller:

```
public function myAction
{
    ...
    return view('home', ['layoutClass'=>'dark']);
}

<header class="{{ isset($layoutClass) ? $layoutClass:'') }} />

```

or you can match the route in the view:

```
<header class="{{ (\Request::route()->getName() == 'myRoute') ? 'dark':'') }} />

```
I found the best way for me was to use an if statement in blade and check the route, below is how I done it:

```
@if (\Request::is('/'))  
    <img class="nav-logo" src="img/logo-light.svg">
@else
    <img class="nav-logo" src="img/logo-dark.svg">
@endif

```