<nav class="navbar navbar-expand-lg navbar-light  bg-light fixed-top py-3 d-block" data-navbar-on-scroll="data-navbar-on-scroll">
  <div class="container">
    <a class="navbar-brand d-inline-flex" href="<?php echo e(url('/')); ?>"><img class="d-inline-block" src="<?php echo e(asset('images/logo3.png')); ?>" alt="logo" /></a>
    <button class="navbar-toggler collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button>
    <div class="collapse navbar-collapse border-top border-lg-0 mt-4 mt-lg-0 justify-content-end" id="navbarSupportedContent">
      <form action="<?php echo e(route('search.index')); ?>" class="me-3 w-75 mb-2">
        <div class="position-relative">
          <div class="form-outline">
            <input type="search" class="typeahead form-control" id="product_search" name="name" placeholder="search product name..." />
               
          </div>
          <button type="submit" class="btn btn-primary search ">
            <i class="fas fa-search"></i>
          </button>
        </div>
      </form>
      <?php
              use App\Models\CartItem;
            if(auth()->check()){
              $cartItems = CartItem::where(['user_id' => auth()->user()->id,'status' => 1])->get();
            }
          ?>
      
      
        
        <a class="text-1000" href="<?php echo e(route('cart.index')); ?>">
          <div class="me-3">
          <svg class="feather feather-shopping-cart" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
            <circle cx="9" cy="21" r="1"></circle>
            <circle cx="20" cy="21" r="1"></circle>
            <path d="M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6"></path>
          </svg>
            <?php if(auth()->check()): ?>
                <span id="cart_no"><?php echo e($cartItems->count()); ?></span>
                <?php else: ?>
                   <span id="cart_no"></span>
                <?php endif; ?>
          </div>
        </a>
        
        <?php if(auth()->guard()->guest()): ?>
          <?php if(Route::has('login')): ?>
            <a class="text-1000" href="<?php echo e(route('login')); ?>">
              <svg class="feather feather-user me-3" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                <path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path>
                <circle cx="12" cy="7" r="4"></circle>
              </svg>
            </a>
          <?php endif; ?>
        <?php else: ?>
          <a class="text-1000" href="<?php echo e(route('user_profile')); ?>">
              <svg class="feather feather-user me-3" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                <path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path>
                <circle cx="12" cy="7" r="4"></circle>
              </svg>
            </a>
          <a class="text-1000" href="<?php echo e(route('logout')); ?>" onclick="event.preventDefault();
            document.getElementById('d-logout-form').submit();">
            logout
          </a>
          <form id="d-logout-form" action="<?php echo e(route('logout')); ?>" method="POST" class="d-none">
            <?php echo csrf_field(); ?>
          </form>
        <?php endif; ?>
      
    </div>
  </div>
</nav>

<!-- Script -->

<script type="text/javascript">

    // CSRF Token
    var CSRF_TOKEN = $('meta[name="csrf-token"]').attr('content');
    $(document).ready(function(){

      $( "#product_search" ).autocomplete({
        source: function( request, response ) {
          // Fetch data
          $.ajax({
            url:"<?php echo e(route('autocomplete')); ?>",
            type: 'get',
            dataType: "json",
            data: {
               _token: CSRF_TOKEN,
               search: request.term
            },
            success: function( data ) {
               response( data );
            }
          });
        },
        select: function (event, ui) {
           // Set selection
              // console.log(ui.item.label);
           $('#product_search').val(ui.item.label); // display the selected text
          //  $('#productid').val(ui.item.value); // save selected id to input
           return false;
        }
      });

    });
    </script>
    <?php /**PATH C:\xampp\htdocs\chittar\resources\views/partials/header.blade.php ENDPATH**/ ?>