Support the ongoing development of Laravel.io →
Requests Views Blade
Last updated 2 years ago.
0

Finally found out a way to do it! :D

<a  class="home-link" @if (Request::path() == 'home')  @elseif (Request::url() == Request::root())
                     data-scroll href="#home" @else  href="home"@endif> Home</a>

I compared Request::url to Request::root as root will always return the root, so if current url is root do this code else this. I'm sure there are other better ways, but I'm happy now :D

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.