<?php foreach($notifications as $notification): ?>
    <div class="notification">
        <div class="notification-title text-success"><?php echo e(ucwords($notification['type'])); ?> <?php echo e($notification['relatedId']); ?></div>
        <div class="notification-description"><?php echo e($notification['content']); ?></div>
        <div class="notification-ago"><?php echo e(date('d/m/Y H:i:s', strtotime($notification['updated_at']))); ?></div>
        <a onclick="javascript:dismissNotification('<?php echo e($notification["id"]); ?>')"><div class="notification-icon fa fa-trash-o bg-success"></div></a>
    </div>
<?php endforeach; ?>

<script type="text/javascript">
    $('#notificationTotal').html('<?php echo e(sizeof($notifications)); ?>');

    if('<?php echo e(sizeof($notifications)); ?>' > 0) {
        $('#notificationIcon').addClass('faa-flash animated');
    }else {
        $('#notificationIcon').removeClass('faa-flash animated');
    }

    function dismissNotification(notificationId) {
        loadingOverlay();
        $.post('<?php echo e(URL::action("NotificationController@dismissNotification")); ?>', {
            notificationId: notificationId,
            _token: '<?php echo e(csrf_token()); ?>'
        }).done(function (data) {
            loadingRemove();
            getNotification('<?php echo e(URL::action("NotificationController@generateUserNotificationList")); ?>', '<?php echo e(Auth::user()["id"]); ?>');
        }).fail(function (data) {
            loadingRemove();
            new PNotify({
                title: 'Notification dismiss failed!',
                text: '',
                type: 'error',
                icon: 'fa fa-times'
            });
        });
    }
</script>