Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect if current page is the web root

Tags:

php

laravel

Looking for the simplest way of checking via PHP if the current page is the root '/'

I only want to show a certain element on the root of my website, but using a blade template and have this certain element in the template for all pages.

Thanks.

E.g.

<?php
  if ($page == $root) {
    // show
  }
?>

If it helps I am using Laravel 4.2.

like image 290
Lovelock Avatar asked Dec 26 '14 01:12

Lovelock


1 Answers

Within the Blade templating of Laravel, the following would suffice

@if(Request::is('/'))
    // The condition you require
@endif
like image 186
Grant Avatar answered Sep 23 '22 06:09

Grant