Search code examples
laravelviewlaravel-bladelaravel-6

How to check Request::is('/new/*') in Blade view in Laravel 6


How can I check Request::is('/new/*') in a Blade view in Laravel 6? I have no sidebar on the home page. However, I want the sidebar on domain.com/new/x pages like domain.com/new/231.

Here's what I did, but it's not working.

@if(Request::is('/new/*'))
    @include('inc.sidebar')
@endif

Solution

  • Are you trying to match routes or URLs? Can you show your routes in web.php?

    @if (\Request::is('new/*')) { 
        // will match URL /new/231 or /new/x
    @endif