How to Check If Current Page is Home Page in Laravel
The Laravel homepage is the main page of a website or web application made with the Laravel Framework. It is the first page that a user sees when visiting the website. The homepage usually contains the main navigation menu, a search bar, and a few featured items.
There are times when you need to check if the current page is the home page, for example, to add a class “active” to the home page menu item.
In Laravel, this can be done using the Request::is method or route check.
//in view {!! Request::is('/') ? '' : url('/') !!} //define route name in route file then check with getName() method in view Route::get('/', ['as'=>'homepage', 'uses'=>'HomeController@index']); @if(request()->route()->getName() == 'homepage') // @else // @endif