0

I have the following route group:

Route::group(['prefix' => 'admin'], function () {

     Route::get('/', 'PagesController@index');

     // some more routes...
});

In my layout file I have the following condition:

 @if (Request::is('admin/*'))
            @include('layouts.partials.admin_header')
 @else
            @include('layouts.partials.header')
 @endif

When I navigate to www.examplesite.com/admin/ it's not displaying in the admin header file?

Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291
adam78
  • 9,668
  • 24
  • 96
  • 207

1 Answers1

1

This is because when you have in browser www.examplesite.com/admin/ Laravel will see url is admin so admin/* pattern will not match in this case because there won't be slash in url. To fix this it seems you should use:

@if (Request::is('admin','admin/*'))

instead of

@if (Request::is('admin/*'))

in your Blade file.

Now both /admin/ and /admin/whatever should work and you should get for both of them admin header

Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291