<?php
$nbOfNotification = 0;
foreach (Auth::user()->unreadNotifications as $notification) {
    $nbOfNotification = $nbOfNotification + 1;
} 
?>
<header id="header" class="header">

  <div class="header-menu">

      <div class="col-sm-7">
          <a id="menuToggle" class="menutoggle pull-left"><i class="fa fa fa-tasks"></i></a>
          <div class="header-left">
              <button class="search-trigger"><i class="fa fa-search"></i></button>
              <div class="form-inline">
                  <form class="search-form">
                      <input class="form-control mr-sm-2" type="text" placeholder="{{ trans('admin/header.search_bar')}}" aria-label="Search">
                      <button class="search-close" type="submit"><i class="fa fa-close"></i></button>
                  </form>
              </div>

              <div class="dropdown for-notification">
                <button class="btn btn-secondary dropdown-toggle" type="button" id="notification" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                  <i class="fa fa-bell"></i>
                  <?php
                    if($nbOfNotification != 0){ ?>
                        <span class="count bg-danger">{{ $nbOfNotification }}</span>
                    <?php } ?>
                </button>
                <div class="dropdown-menu" aria-labelledby="notification">
                  <?php 
                    foreach (Auth::user()->unreadNotifications as $notification) {
                        echo '<a class="dropdown-item media bg-flat-color-1" href="#"><i class="fa fa-info"></i><p>'.$notification->data['msg'].'</p></a>';
                    }
                  ?>
                </div>
              </div>
          </div>
      </div>

      <div class="col-sm-5">
          <div class="user-area dropdown float-right">
              <a class="btn">{{ Auth::User()->lastname }} {{ Auth::User()->firstname }}</a>
              <a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" >
                  <img class="user-avatar rounded-circle" src="/assets/admin/images/avatar/user-{{ Auth::User()->avatar }}.jpg" alt="User Avatar">
              </a>

              <div class="user-menu dropdown-menu">
                      <a class="nav-link" href="/admin/profil"><i class="fa fa-user"></i> {{ trans('admin/header.profil')}}</a>
                      <a class="nav-link" href="/admin/settings"><i class="fa fa-cog"></i> {{ trans('admin/header.settings')}}</a>
                      <a class="nav-link" href="/logout"><i class="fa fa-power-off"></i> {{ trans('admin/header.logout')}}</a>
              </div>
          </div>

          <!--<div class="language-select dropdown" id="language-select">
              <a class="dropdown-toggle" href="#" data-toggle="dropdown"  id="language" aria-haspopup="true" aria-expanded="true">
                  <i class="flag-icon flag-icon-ca"></i>
              </a>
              <div class="dropdown-menu" aria-labelledby="language" >
                  <div class="dropdown-item">
                      <span class="flag-icon flag-icon-us"></span>
                  </div>
              </div>
          </div>-->

      </div>
  </div>

</header><!-- /header -->
