<?php echo $__env->make('vendor.ueditor.assets', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
<?php $__env->startSection('content'); ?>

    <div class="container">
        <div class="col-md-10 offset-md-1">
            <div class="card ">

                <div class="card-body">
                    <h2 class="">
                        <i class="far fa-edit"></i>
                        <?php if($post->id): ?>
                            编辑话题
                        <?php else: ?>
                            新建话题
                        <?php endif; ?>
                    </h2>

                    <hr>

                    <?php if($post->id): ?>
                        <form action="<?php echo e(route('posts.update', $post->id), false); ?>" method="POST" accept-charset="UTF-8">
                            <input type="hidden" name="_method" value="PUT">
                            <?php else: ?>
                                <form action="<?php echo e(route('posts.store'), false); ?>" method="POST" accept-charset="UTF-8">
                                    <?php endif; ?>

                                    <input type="hidden" name="_token" value="<?php echo e(csrf_token(), false); ?>">

                                    <?php echo $__env->make('shared._error', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

                                    <div class="form-group">
                                        <input class="form-control" type="text" name="title"
                                               value="<?php echo e(old('title', $post->title ), false); ?>" placeholder="请填写标题" required/>
                                    </div>
                                    <div class="form-group">
                                        <select class="form-control" name="category_id" required>
                                            <option value="" hidden disabled selected>请选择分类</option>
                                            <?php $__currentLoopData = $categories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <option value="<?php echo e($value->id, false); ?>" <?php echo e(old('category_id',$post->category_id) == $value->id ? 'selected':'', false); ?>><?php echo e($value->title, false); ?></option>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        </select>
                                    </div>
                                    <div class="form-group">
                                        <script id="container" name="content"
                                                type="text/plain">
                                            <?php echo old('content', $post->content ); ?>

                                        </script>
                                    </div>
                                    <div class="well well-sm">
                                        <button type="submit" class="btn btn-primary"><i class="far fa-save mr-2"
                                                                                         aria-hidden="true"></i> 保存
                                        </button>
                                    </div>
                                </form>
                </div>
            </div>
        </div>
    </div>
    <!-- 实例化编辑器 -->
    <script type="text/javascript">
        var ue = UE.getEditor('container');
        ue.ready(function () {
            ue.execCommand('serverparam', '_token', '<?php echo e(csrf_token(), false); ?>'); // 设置 CSRF token.
        });
    </script>

    <!-- 编辑器容器 -->
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\Users\Administrator\Desktop\1\jiangqiangdexiaocao-master\resources\views/posts/create_and_edit.blade.php ENDPATH**/ ?>