<div class="p-3 card-header-border">
    <h6 class="text-center">
        <?php echo e(__('message.notification')); ?>   <small class="badge badge-light float-right pt-1 notification_count notification_tag"> <?php echo e($all_unread_count); ?></small>
    </h6>
</div>
<div class="px-2 py-2">
    <h6 class="text-sm text-muted m-0"><span class="notification_count"><?php echo e(__('message.you_have_unread_notification',['number' => $all_unread_count ])); ?></span>
        <?php if($all_unread_count > 0 ): ?>
            <a href="#" data-type="markas_read" class="notifyList float-right" ><span><?php echo e(__('message.mark_all_as_read')); ?></span></a>
        <?php endif; ?>
    </h6>
</div>

<?php if(isset($notifications) && count($notifications) > 0): ?>
    <div class="notification-height">
        <?php $__currentLoopData = $notifications->sortByDesc('created_at')->take(5); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $notification): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <?php
                if( $notification->data['type'] == 'complaintcomment' ) {
                    $notification_id = $notification->data['complaint_id'];
                    $route = null;
                } else {
                    $notification_id = $notification->data['id'];
                    $route = null;
                }
            ?>
            <a href="<?php echo e($route); ?>" class="sub-card <?php echo e($notification->read_at ? '':'notify-list-bg'); ?>">
                <div class="media align-items-center">
                    <div class="media-body ml-3">
                        <h6 class="mb-0">#<?php echo e($notification_id); ?> <?php echo e(__('message.'.$notification->data['type'])); ?></h6>
                        <small class="float-right font-size-12"><?php echo e(timeAgoFormate($notification->created_at)); ?></small>
                        <p class="mb-0"><?php echo e(isset($notification->data['message']) ? $notification->data['message'] : __('message.booked')); ?></p>
                    </div>
                </div>
            </a>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    </div>
    <a href="<?php echo e(route('notification.index')); ?>" class="dropdown-item text-center text-primary font-weight-bold py-3"><?php echo e(__('message.view_all')); ?></a>
<?php else: ?>
    <a href="#" class="sub-card">
        <div class="media align-items-center">
            <div class="media-body ml-3">
                <h6 class="mb-0"><?php echo e(__('message.no_notification')); ?></h6>
                <small class="float-right font-size-12"></small>
                <p class="mb-0"></p>
            </div>
        </div>
    </a>
<?php endif; ?>
<script>
    $('.notifyList').on('click',function() {
        notificationList($(this).attr('data-type'));
    });

    $(document).on('click','.notification_data',function(event) {
        event.stopPropagation();
    })

    function notificationList(type='') {
        var url = "<?php echo e(route('notification.list')); ?>";
        $.ajax({
            type: 'get',
            url: url,
            data: {'type':type},
            success: function(res) {

                $('.notification_data').html(res.data);
                getNotificationCounts();
                if(res.type == "markas_read") {
                    notificationList();
                }
                $('.notify_count').removeClass('notification_tag').text('');
            }
        });
    }

    function getNotificationCounts() {
        var url = "<?php echo e(route('notification.counts')); ?>";
        $.ajax({
            type: 'get',
            url: url,
            success: function(res) {
                if(res.counts > 0) {
                    $('.notify_count').addClass('notification_tag').text(res.counts);
                    setNotification(res.counts);
                    $('.notification_list span.dots').addClass('d-none')
                    $('.notify_count').removeClass('d-none')
                } else {
                    $('.notify_count').addClass('d-none')
                    $('.notification_list span.dots').removeClass('d-none')
                }

                if(res.counts <= 0 && res.unread_total_count > 0) {
                    $('.notification_list span.dots').removeClass('d-none')
                } else {
                    $('.notification_list span.dots').addClass('d-none')
                }
            }
        });
    }
</script><?php /**PATH /home/atharvatek/mxunzo.atharvatek.com/resources/views/notification/list.blade.php ENDPATH**/ ?>