<?php $__env->startSection('maincontent'); ?>
<?php $__env->startSection('title'); ?>
    <?php echo e(env('APP_NAME')); ?>-Search Products
<?php $__env->stopSection(); ?>

<style>
    #checked {
        color: orange;
    }
    .star{
        font-size: 8px !important;
    }

    #featureimageCt {
        height: 300px;
        width: auto;
        padding: 2px;
        padding-top: 0;
    }
    @media  only screen and (max-width: 600px) {
       #featureimageCt {
            height: 220px;
            width: auto;
            padding: 2px;
            padding-top: 0;
        }
    }
</style>
<div class="body-content outer-top-xs">
    <div class="breadcrumb pt-2">
        <div class="container">
            <div class="row">
                <div class="col-12">
                    <div class="breadcrumb-inner p-0">
                        <ul class="list-inline list-unstyled mb-0">
                            <li><a href="#"
                                    style="text-transform: capitalize !important;color: #888;padding-right: 12px;font-size: 12px;">Home
                                    > Search > <span class="active"></span>Products</span>
                                </a></li>
                        </ul>
                    </div>
                </div>
                <!-- /.breadcrumb-inner -->
            </div>
        </div>
        <!-- /.container -->
    </div>


    <div class='container'>
        <div class='row'>
            <!-- /.sidebar -->
            <div class='col-md-12' id="cateoryPro">
                <div class="container" >

                    <div class="row pt-2 pb-2" style="background: white;">

                        <?php $__empty_1 = true; $__currentLoopData = $searchproducts; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $searchproduct): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>

                            <?php
                                $firstcatepro=App\Models\Product::where('id',json_decode($searchproduct->RelatedProductIds)[0]->productID)->first();
                            ?>
                            <?php if(isset($firstcatepro)): ?>
                                <div class="col-6 col-md-4 col-lg-2 mb-2">
                                    <div class="product">
                                        <div class="product-micro">
                                            <div class="row product-micro-row">
                                                <div class="col-12">
                                                    <div class="product-image" style="position: relative;">
                                                        <div class="image text-center">
                                                            <a href="<?php echo e(url('view-product/' . $searchproduct->ProductSlug)); ?>">
                                                                <img src="<?php echo e(asset($searchproduct->ProductImage)); ?>"
                                                                    alt="<?php echo e($searchproduct->ProductName); ?>" id="featureimage">
                                                            </a>
                                                        </div>
                                                        <?php if(App\Models\Size::where('product_id',$firstcatepro->id)->first()): ?>
                                                            <span id="discountpart"> <p id="pdis">SAVE ৳<?php echo e(round(App\Models\Size::where('product_id',$firstcatepro->id)->first()->Discount)); ?></p></span>
                                                        <?php else: ?>
                                                            <span id="discountpart"> <p id="pdis">SAVE ৳<?php echo e(round(App\Models\Weight::where('product_id',$firstcatepro->id)->first()->Discount)); ?></p></span>
                                                        <?php endif; ?>
    
                                                    </div>
                                                    <!-- /.product-image -->
                                                </div>
                                                <!-- /.col -->
                                                <div class="col-12">
                                                    <div class="infofe p-md-2 p-2" style="border-top:none;background: white;">
                                                        <div class="product-info">
                                                            <h2 class="name text-truncate" id="f_name"><a
                                                                    href="<?php echo e(url('view-product/' . $searchproduct->ProductSlug)); ?>"
                                                                    id="f_pro_name"><?php echo e($firstcatepro->ProductName); ?></a>
                                                            </h2>
                                                        </div>
    
                                                        <?php
                                                            $review = App\Models\Review::where('product_id', $firstcatepro->id)->avg(
                                                                'rating',
                                                            );
                                                        ?>
                                                        <div class="d-flex" style="justify-content:space-between">
                                                            <div class="star" style="padding-top: 5px;">
                                                                <span style="font-weight: bold;color:black;font-size:10px">(<?php echo e(App\Models\Review::where('product_id', $firstcatepro->id)->get()->count()); ?>)</span>
                                                                <?php if(intval($review) == 1): ?>
                                                                    <span class="fas fa-star" id="checked"></span>
                                                                    <span class="fas fa-star"></span>
                                                                    <span class="fas fa-star"></span>
                                                                    <span class="fas fa-star"></span>
                                                                    <span class="fas fa-star"></span>
                                                                <?php elseif(intval($review) == 2): ?>
                                                                    <span class="fas fa-star" id="checked"></span>
                                                                    <span class="fas fa-star" id="checked"></span>
                                                                    <span class="fas fa-star"></span>
                                                                    <span class="fas fa-star"></span>
                                                                    <span class="fas fa-star"></span>
                                                                <?php elseif(intval($review) == 3): ?>
                                                                    <span class="fas fa-star" id="checked"></span>
                                                                    <span class="fas fa-star" id="checked"></span>
                                                                    <span class="fas fa-star" id="checked"></span>
                                                                    <span class="fas fa-star"></span>
                                                                    <span class="fas fa-star"></span>
                                                                <?php elseif(intval($review) == 4): ?>
                                                                    <span class="fas fa-star" id="checked"></span>
                                                                    <span class="fas fa-star" id="checked"></span>
                                                                    <span class="fas fa-star" id="checked"></span>
                                                                    <span class="fas fa-star" id="checked"></span>
                                                                    <span class="fas fa-star"></span>
                                                                <?php elseif(intval($review) == 5): ?>
                                                                    <span class="fas fa-star" id="checked"></span>
                                                                    <span class="fas fa-star" id="checked"></span>
                                                                    <span class="fas fa-star" id="checked"></span>
                                                                    <span class="fas fa-star" id="checked"></span>
                                                                    <span class="fas fa-star" id="checked"></span>
                                                                <?php else: ?>
                                                                    <span class="fas fa-star" id="checked"></span>
                                                                    <span class="fas fa-star" id="checked"></span>
                                                                    <span class="fas fa-star" id="checked"></span>
                                                                    <span class="fas fa-star" id="checked"></span>
                                                                    <span class="fas fa-star" id="checked"></span>
                                                                <?php endif; ?>
                                                            </div>
                                                            <div class="like">
                                                                <div class="d-flex" style="justify-content: space-around;font-size: 14px;">
                                                                    <span style="padding-right:14px;"><span class="sts" style="padding-right: 2px;font-size:12px;"
                                                                            id="likereactof<?php echo e($firstcatepro->id); ?>"><?php echo e(App\Models\React::where('product_id', $firstcatepro->id)->where('sigment','like')->get()->count()); ?></span><i
                                                                            <?php if(App\Models\React::where('product_id', $firstcatepro->id)->whereIn('user_id', [\Request::ip(),Auth::id()])->where('sigment','like')->first()): ?> style="color:green !important" <?php endif; ?> class="fas fa-thumbs-up" id="likereactdone<?php echo e($firstcatepro->id); ?>"
                                                                            onclick="givereactlike(<?php echo e($firstcatepro->id); ?>)"></i></span>
                                                                    <span><span class="sts" style="padding-right: 2px;font-size:12px;"
                                                                            id="lovereactof<?php echo e($firstcatepro->id); ?>"><?php echo e(App\Models\React::where('product_id', $firstcatepro->id)->where('sigment','love')->get()->count()); ?></span><i
                                                                            <?php if(App\Models\React::where('product_id', $firstcatepro->id)->whereIn('user_id', [\Request::ip(),Auth::id()])->where('sigment','love')->first()): ?> style="color:red !important" <?php endif; ?> class="fas fa-heart" id="lovereactdone<?php echo e($firstcatepro->id); ?>"
                                                                            onclick="givereactlove(<?php echo e($firstcatepro->id); ?>)"></i></span>
                                                                </div>
                                                            </div>
                                                        </div>
    
                                                        <?php if(App\Models\Size::where('product_id',$firstcatepro->id)->first()): ?>
                                                        <div class="price-box">
                                                            <del class="old-product-price strong-400">৳
                                                                <?php echo e(round(App\Models\Size::where('product_id',$firstcatepro->id)->first()->RegularPrice)); ?></del>
                                                            <span
                                                                class="product-price strong-600">৳ <?php echo e(round(App\Models\Size::where('product_id',$firstcatepro->id)->first()->SalePrice)); ?></span>
                                                        </div>
                                                        <?php else: ?>
                                                        <div class="price-box">
                                                            <del class="old-product-price strong-400">৳
                                                                <?php echo e(round(App\Models\Weight::where('product_id',$firstcatepro->id)->first()->RegularPrice)); ?></del>
                                                            <span
                                                                class="product-price strong-600">৳ <?php echo e(round(App\Models\Weight::where('product_id',$firstcatepro->id)->first()->SalePrice)); ?></span>
                                                        </div>
                                                        <?php endif; ?>
    
                                                    </div>
    
                                                    <a href="<?php echo e(url('view-product/' . $searchproduct->ProductSlug)); ?>">
                                                        <button class="btn btn-danger btn-sm mb-0 btn-block"
                                                                style="width: 100%;border-radius: 0%;" id="purcheseBtn">অর্ডার করুন</button>
                                                    </a>
                                                </div>
                                                <!-- /.col -->
                                            </div>
                                            <!-- /.product-micro-row -->
                                        </div>
                                    </div>
                                </div>
                            <?php endif; ?>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                            <h2 class="p-4 text-center"><b>No Products found...</b></h2>
                        <?php endif; ?>
                    </div>

                </div>
                <!-- /.category-product -->


                <!-- /.tab-content -->
                <div class="clearfix filters-container">
                    <div class="text-right">
                        <div class="pagination-container">

                        </div>
                        <!-- /.pagination-container -->
                    </div>
                    <!-- /.text-right -->

                </div>
                <!-- /.filters-container -->

            </div>
            <!-- /.col -->
        </div>

        <!-- ============================================== BRANDS CAROUSEL : END ============================================== -->
    </div>
    <!-- /.container -->

</div>
<?php if(Auth::id()): ?>
    <input type="hidden" name="user_id" id="user_id" value="<?php echo e(Auth::id()); ?>">
<?php else: ?>
    <input type="hidden" name="user_id" id="user_id" >
<?php endif; ?>

<script>
    function givereactlike(id) {
        $.ajax({
            type: 'GET',
            url: '<?php echo e(url('give/react/')); ?>'+'/like',
            data: {
                'user_id': $('#user_id').val(),
                'product_id': id,
            },

            success: function(data) {
                if (data.sigment == 'like') {
                    $('#cateoryPro #likereactof' + id).text(data.total);
                    $('#cateoryPro #likereactdone' + id).css('color', 'orange');
                }else if (data.sigment == 'unlike') {
                    $('#cateoryPro #likereactof' + id).text(data.total);
                    $('#cateoryPro #likereactdone' + id).css('color', 'black');
                }else {

                }
            },
            error: function(error) {
                console.log('error');
            }
        });
    }

    function givereactlove(id) 
    {
        $.ajax({
            type: 'GET',
            url: '<?php echo e(url('give/react/')); ?>'+'/love',
            data: {
                'user_id': $('#user_id').val(),
                'product_id': id,
            },

            success: function(data) {
                if (data.sigment == 'love') {
                    $('#cateoryPro #lovereactof' + id).text(data.total);
                    $('#cateoryPro #lovereactdone' + id).css('color', 'orange');
                } else {
                    $('#cateoryPro #lovereactof' + id).text(data.total);
                    $('#cateoryPro #lovereactdone' + id).css('color', 'black');
                }
            },
            error: function(error) {
                console.log('error');
            }
        });
    }
</script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('webview.master', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/jafrafas/jaframart.com/resources/views/webview/content/product/mainsearch.blade.php ENDPATH**/ ?>