

<?php $__env->startSection('title', 'Books'); ?>

<?php $__env->startSection('content'); ?>
<div class="page-content">
    <div class="container-fluid">
        <div class="row">
            <div class="col-lg-12">
                <div class="card">
                    <div class="card-header">
                        <h4 class="card-title">Books</h4>
                        <a href="<?php echo e(route('books.create')); ?>" class="btn btn-primary btn-sm float-end">Add Book</a>
                    </div>
                    <div class="card-body">
                        <div class="table-responsive">
                            <table class="table table-bordered table-striped">
                                <thead>
                                    <tr>
                                        <th>ID</th>
                                        <th>Title</th>
                                        <th>Author</th>
                                        <th>Publisher</th>
                                        <th>Category</th>
                                        <th>Cover Image</th>
                                        <th>Actions</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php $__currentLoopData = $books; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $book): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <tr>
                                        <td><?php echo e($book->id); ?></td>
                                        <td><?php echo e($book->title); ?></td>
                                        <td><?php echo e($book->author); ?></td>
                                        <td><?php echo e($book->publisher); ?></td>
                                        <td><?php echo e($book->category->name); ?></td>
                                        <td>
                                            <!-- Display Cover Image -->
                                            <?php if(file_exists(public_path($book->cover_image))): ?>
                                                <img src="<?php echo e(asset($book->cover_image)); ?>" alt="Cover Image" width="50" class="img-thumbnail">
                                            <?php else: ?>
                                                <span class="text-danger">Image missing</span>
                                            <?php endif; ?>
                                        </td>
                                        <td>
                                            <!-- View PDF Button -->
                                            <?php if(file_exists(public_path($book->file))): ?>
                                                <a href="<?php echo e(asset($book->file)); ?>" target="_blank" class="btn btn-sm btn-info">View PDF</a>
                                            <?php else: ?>
                                                <button class="btn btn-sm btn-secondary" disabled>PDF missing</button>
                                            <?php endif; ?>
                                            
                                            <!-- Edit Button -->
                                            <a href="<?php echo e(route('books.edit', $book->id)); ?>" class="btn btn-sm btn-warning">Edit</a>
                                            
                                            <!-- Delete Button -->
                                            <form action="<?php echo e(route('books.destroy', $book->id)); ?>" method="POST" class="d-inline">
                                                <?php echo csrf_field(); ?>
                                                <?php echo method_field('DELETE'); ?>
                                                <button type="submit" class="btn btn-sm btn-danger" onclick="return confirm('Are you sure?')">Delete</button>
                                            </form>
                                        </td>
                                    </tr>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/u180427332/domains/lime-stinkbug-754807.hostingersite.com/public_html/mulikat/resources/views/dashboard/books/index.blade.php ENDPATH**/ ?>