Ahmed Nawaz Khan
Ahmed Nawaz Khan

Reputation: 1806

using Request::is() function with named Routes Laravel

I was doing Request::is('/') which gave me true for example.com Now I am using named routes and for the name welcome

Route::get('/', function () {
    return view('admin_panel.welcome');
})->name('welcome');

Request::is(route('welcome')) returns false

What should I do. Note: I am using this for active states in navigation

Upvotes: 3

Views: 12294

Answers (2)

Ahmed Nawaz Khan
Ahmed Nawaz Khan

Reputation: 1806

I achieved this using Request::url() == route('welcome')which gave me truefor example.com

Upvotes: 0

Rwd
Rwd

Reputation: 35200

You can use the routeIs method:

Request::routeIs('welcome');

Upvotes: 15

Related Questions