eComEvo
eComEvo

Reputation: 12559

Detecting if route is part of a resource

Is there a standard Laravel way to check if a named route is part of a resource?

For instance, in a Blade template I can do:

@if(strpos(Route::currentRouteName(), 'posts') === 0)
     Yep, you're viewing a post.index, post.edit, post.preview, etc.
@else
     Nothing to do with a post.
@if

Wondering if I've glossed over some standard way of doing it or if this is it.

Upvotes: 1

Views: 383

Answers (1)

eComEvo
eComEvo

Reputation: 12559

And I just figured it out:

Route::is('posts.*')

Upvotes: 5

Related Questions