0

I have a helper function.

function setActive($path, $active = 'active')
{
    return call_user_func_array('Request::is', (array)$path) ? $active : '';
}

When I go to the site: http://example.net/posts?group=active, my function is not working and returns an empty string ("").

I use this in my Blade:

class="{{ setActive(['posts?group=active'] }}"

How can I resolve this?

Karl Hill
  • 12,937
  • 5
  • 58
  • 95
Dumitru
  • 2,053
  • 6
  • 20
  • 45

1 Answers1

0

Is this for navigation? You don't need a helper function to achieve that. In your blade, you can just do...

@if(request()->is() === 'posts')

OR

{{ request()->is('posts') ? 'active' : '' }}
Karl Hill
  • 12,937
  • 5
  • 58
  • 95