Check route with variable in Laravel 5.1

2

I'm using the code below to assign the "active" class when on the "product" or "product / create" route.

<li {!! Request::is('produto', 'produto/create')? 'class="active"' : null !!}>

Now I need to do the same in the product edition, the editing route has a variable that is the product id, how do I solve it?

Example routes:

produto/1/edit
produto/7/edit
    
asked by anonymous 08.05.2017 / 16:29

1 answer

2

The Request::is method accepts wildcards ( * ) according to the documentation .

  

The is method allows you to verify that the incoming request URI   matches a given pattern. You may use the * character as a wildcard   when using this method:

if ($request->is('admin/*')) {
    //
}

In your case, try the following

<li {!! Request::is('produto/*/edit')? 'class="active"' : null !!}>
    
08.05.2017 / 17:06