<?php
$nbOfNotification = 0;
foreach (Auth::user()->unreadNotifications as $notification) {
    $nbOfNotification = $nbOfNotification + 1;
} 
?>
<nav class="navbar navbar-default">
    <div class="container-fluid">
        <div class="navbar-header">
                <button type="button" class="navbar-toggle">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar bar1"></span>
                    <span class="icon-bar bar2"></span>
                    <span class="icon-bar bar3"></span>
                </button>
            </div>
        <div class="collapse navbar-collapse">
            <ul class="nav navbar-nav navbar-right">
                <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                            <i><img src="/assets/icons/alarm.svg" style="height:20px;margin-top:-8px;"></i>
                            <p class="notification">{{$nbOfNotification}}</p>
                            <p>Notifications</p>
                            <b class="caret"></b>
                        </a>
                        <ul class="dropdown-menu">
                        <li><a href="/ecc/notication/mark" class="btn btn-warning">Marquer toutes les notifications comme lue</a></li>
                        @foreach (Auth::user()->unreadNotifications as $notification)
                           <li style="width:250px"><form method="post" action="/ecc/notication/mark/{{$notification->id}}">{{csrf_field()}}<button style="border:none;margin:5px;background-color:white" name="url" type="submit" value="{{$notification->data['url']}}"><p>{{$notification->data['msg']}}</p></button></form></li>
                        @endforeach

                        </ul>
                </li>
                <li>
                    <a href="/ecc/settings">
                        <i><img src="/assets/icons/settings.svg" style="height:20px;margin-top:-8px;"></i>
                        <p>Options</p>
                    </a>
                </li>
                <li>
                    <a href="/logout">
                        <p>Déconnexion</p>
                    </a>
                </li>
            </ul>

        </div>
    </div>
</nav>