<?php $menu = app('App\Models\Other\Other'); ?>

<?php $__env->startSection('container'); ?>
    <div class="row">
        <!-- left column -->
        <div class="col-md-12">
            <!-- jquery validation -->
            <?php if(session()->has('error')): ?>
                <div class="alert alert-danger text-center">
                    <?php echo e(session()->get('error')); ?>

                </div>
            <?php endif; ?>
            <?php if(session()->has('success')): ?>
                <div class="alert alert-success text-center">
                    <?php echo e(session()->get('success')); ?>

                </div>
            <?php endif; ?>
            <div class="card">
                <div class="card-header">
                    <strong>
                        <h3 class="card-title">รายการสินค้าทั้งหมด</h3>
                    </strong>
                </div>
                <!-- /.card-header -->
                <div class="card-body">
                    <table id="example1" class="table table-bordered table-striped">
                        <thead>
                            <tr>
                                <th class="text-center text-nowrap">#</th>
                                <th class="text-center text-nowrap">ชื่อสินค้า</th>
                                <th class="text-center text-nowrap">ราคา</th>
                                <th class="text-center text-nowrap">หมวดหมู่</th>
                                <th class="text-center text-nowrap">คุณลักษณะ</th>
                                <th class="text-center text-nowrap">คุณสมบัติ</th>
                                <th class="text-center text-nowrap">รูปภาพ</th>
                                <th class="text-center text-nowrap">ดำเนินการ</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $__currentLoopData = $data; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $rows): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <tr>
                                    <td class="text-center"><?php echo e(++$key); ?></td>
                                    <td><?php echo e($rows->products_name); ?></td>
                                    <td class="text-center"><?php echo e($rows->products_price); ?></td>
                                    <td class="text-center">
                                        <?php
                                            $datamenu = $menu->productmenu();
                                        ?>
                                        <?php $__currentLoopData = $datamenu; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $rows2): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <?php if($rows2->id == $rows->products_categorys): ?>
                                                <?php echo e($rows2->categorys_names); ?>

                                            <?php endif; ?>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </td>
                                    <td><?php echo e($rows->products_attribute ?  $rows->products_attribute : '-'); ?></td>
                                    <td><pre><?php echo e($rows->products_detail); ?></pre></td>
                                    <td class="text-center">
                                        <img src="<?php echo e(asset('' . $rows->products_img . '')); ?>" class="img-fluid"
                                            alt="<?php echo e($rows->products_name); ?>" width="200" height="200">
                                    </td>
                                    <td class="text-center">
                                        <form action="<?php echo e(route('products.destroy', $rows->id)); ?>" method="POST">
                                            <?php echo csrf_field(); ?>

                                            <a class="btn btn-info btn-sm"
                                                href="<?php echo e(route('products.edit', $rows->id)); ?>">
                                                <i class="fas fa-pencil-alt">
                                                </i>
                                            </a>
                                            <?php echo method_field('DELETE'); ?>
                                            <button type="submit" class="btn btn-danger btn-sm"
                                                onclick="return confirm('ต้องการลบรายการนี้หรือไม่')">
                                                <i class="fas fa-trash">
                                                </i>
                                            </button>
                                        </form>
                                    </td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </tbody>
                    </table>
                    <div class="card-footer text-center">
                        <a href="<?php echo e(asset('/admin/productsform')); ?>">เพิ่มข้อมูลสินค้า</a>
                    </div>
                </div>
                <!-- /.card-body -->
            </div>
            <!-- /.card -->
        </div>
        <!--/.col (left) -->

    </div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('scriptadd'); ?>
    <script src="<?php echo e(asset('template2')); ?>/plugins/datatables/jquery.dataTables.min.js"></script>
    <script src="<?php echo e(asset('template2')); ?>/plugins/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
    <script src="<?php echo e(asset('template2')); ?>/plugins/datatables-responsive/js/dataTables.responsive.min.js"></script>
    <script src="<?php echo e(asset('template2')); ?>/plugins/datatables-responsive/js/responsive.bootstrap4.min.js"></script>
    <script src="<?php echo e(asset('template2')); ?>/plugins/datatables-buttons/js/dataTables.buttons.min.js"></script>
    <script src="<?php echo e(asset('template2')); ?>/plugins/datatables-buttons/js/buttons.bootstrap4.min.js"></script>
    <script>
        $(function() {
            $('#example1').DataTable({});
        });
    </script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('admin.layouts.main', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/thaiuppc/domains/thaiupp.com/public_html/site/resources/views/admin/data/products/products.blade.php ENDPATH**/ ?>