

<?php $__env->startSection('content'); ?>
    <div class="card">
        <div class="card-header"><?php echo e(isset($blog) ? 'Edit' : 'Create'); ?> Blog</div>
        <div class="card-body">
            <form action="<?php echo e(isset($blog) ? route('blogs.update', $blog->id) : route('blogs.store')); ?>" method="POST"
                enctype="multipart/form-data">
                <?php echo csrf_field(); ?>
                <?php if(isset($blog)): ?>
                    <?php echo method_field('PUT'); ?>
                <?php endif; ?>

                <div class="mb-3">
                    <label>Title</label>
                    <input type="text" name="title" class="form-control" value="<?php echo e(old('title', $blog->title ?? '')); ?>"
                        required>
                </div>

                <div class="mb-3">
                    <label>Author</label>
                    <input type="text" name="author" class="form-control"
                        value="<?php echo e(old('author', $blog->author ?? '')); ?>" required>
                </div>

                <div class="mb-3">
                    <label>Category</label>
                    <select name="category_id" class="form-control" required>
                        <option value="">-- Select Category --</option>
                        <?php $__currentLoopData = $categories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $category): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($category->id); ?>"
                                <?php echo e(old('category_id', $blog->category_id ?? '') == $category->id ? 'selected' : ''); ?>>
                                <?php echo e(ucfirst($category->name)); ?>

                            </option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                </div>

                <div class="mb-3">
                    <label>Tag</label>
                    <select name="tag_id" class="form-control" required>
                        <option value="">-- Select Tag --</option>
                        <?php $__currentLoopData = $tags; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $tag): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($tag->id); ?>"
                                <?php echo e(old('tag_id', $blog->tag_id ?? '') == $tag->id ? 'selected' : ''); ?>>
                                <?php echo e(ucfirst($tag->name)); ?>

                            </option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                </div>

                <div class="mb-3">
                    <label>Content</label>
                    <textarea name="content" id="content" class="form-control my-editor" rows="5" required>
                        <?php echo e(old('content', $blog->content ?? '')); ?>

                    </textarea>
                </div>

                <div class="mb-3">
                    <label>Status</label>
                    <select name="status" class="form-control" required>
                        <option value="draft" <?php echo e(old('status', $blog->status ?? '') == 'draft' ? 'selected' : ''); ?>>Draft
                        </option>
                        <option value="published"
                            <?php echo e(old('status', $blog->status ?? '') == 'published' ? 'selected' : ''); ?>>
                            Published</option>
                    </select>
                </div>

                <div class="mb-3">
                    <label>Image</label>
                    <input type="file" name="image" accept="image/*" class="form-control">
                    <?php if(isset($blog) && $blog->image): ?>
                        <div class="mt-2">
                            <img src="<?php echo e(asset($blog->image)); ?>" width="120" alt="Blog Image">
                        </div>
                    <?php endif; ?>
                </div>

                <button class="btn btn-success mt-3"><?php echo e(isset($blog) ? 'Update' : 'Save'); ?></button>
                <a href="<?php echo e(route('blogs.index')); ?>" class="btn btn-secondary mt-3">Cancel</a>
            </form>

        </div>
    </div>
    <script>
        $('#content').summernote({
            placeholder: 'Write something...',
            tabsize: 2,
            height: 100
        });
        $('.dropdown-toggle').dropdown()
    </script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('admin.masterAdmin', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp\htdocs\TGP-hospital-site\resources\views/admin/blog/form.blade.php ENDPATH**/ ?>