edit.blade.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. @extends('theme::layout.public')
  2. @section('seo_title')编辑文章 - {{ Setting()->get('website_name') }}@endsection
  3. @section('css')
  4. <link href="{{ asset('/static/js/summernote/summernote.css')}}" rel="stylesheet">
  5. <link href="{{ asset('/static/js/select2/css/select2.min.css')}}" rel="stylesheet">
  6. <link href="{{ asset('/static/js/select2/css/select2-bootstrap.min.css')}}" rel="stylesheet">
  7. @endsection
  8. @section('content')
  9. <div class="row mt-10">
  10. <ol class="breadcrumb">
  11. <li><a href="{{ route('website.blog') }}">文章</a></li>
  12. <li><a href="{{ route('blog.article.detail',['id'=>$article->id]) }}">{{ $article->title }}</a></li>
  13. <li class="active">编辑文章</li>
  14. </ol>
  15. <div class="col-md-12 main widget-form">
  16. <form id="article_form" method="POST" role="form" enctype="multipart/form-data" action="{{ route('blog.article.update',['id'=>$article->id]) }}">
  17. <input type="hidden" id="editor_token" name="_token" value="{{ csrf_token() }}">
  18. <input type="hidden" id="tags" name="tags" value="{{ $article->tags->implode('name',',') }}" />
  19. <div class="form-group @if($errors->has('title')) has-error @endif ">
  20. <label for="title">文章标题:</label>
  21. <input id="title" type="text" name="title" class="form-control input-lg" placeholder="我想起那天下午在夕阳下的奔跑,那是我逝去的青春" value="{{ old('title',$article->title) }}" />
  22. @if($errors->has('title')) <p class="help-block">{{ $errors->first('title') }}</p> @endif
  23. </div>
  24. <div class="form-group @if($errors->has('logo')) has-error @endif">
  25. <label>文章封面</label>
  26. <input type="file" name="logo" />
  27. @if($article->logo)
  28. <div style="margin-top: 10px;">
  29. <img src="{{ $article->logo }}" style="height:100px;"/>
  30. </div>
  31. @endif
  32. @if($errors->has('logo')) <p class="help-block">{{ $errors->first('logo') }}</p> @endif
  33. </div>
  34. <div class="form-group @if($errors->has('content')) has-error @endif">
  35. <label for="article_editor">文章正文:</label>
  36. <div id="article_editor">{!! old('content', $article->content) !!}</div>
  37. @if($errors->has('content')) <p class="help-block">{{ $errors->first('content') }}</p> @endif
  38. </div>
  39. <div class="form-group">
  40. <label for="editor">文章导读:</label>
  41. <textarea name="summary" class="form-control">{{ $article->summary }}</textarea>
  42. </div>
  43. <div class="row">
  44. <div class="col-xs-4">
  45. <select name="category_id" id="category_id" class="form-control">
  46. <option value="0">请选择分类</option>
  47. @include('admin.category.option',['type'=>'articles','select_id'=>$article->category_id])
  48. </select>
  49. </div>
  50. <div class="col-xs-8">
  51. <select id="select_tags" name="select_tags" class="form-control" multiple="multiple" >
  52. @foreach($article->tags as $tag)
  53. <option selected="selected">{{ $tag->name }}</option>
  54. @endforeach
  55. </select>
  56. </div>
  57. </div>
  58. <div class="row mt-20">
  59. <div class="col-xs-12 col-md-11">
  60. <ul class="list-inline">
  61. @if( Setting()->get('code_create_article') )
  62. <li class="pull-right">
  63. @include('theme::layout.auth_captcha')
  64. </li>
  65. @endif
  66. </ul>
  67. </div>
  68. <div class="col-xs-12 col-md-1">
  69. <input type="hidden" id="article_editor_content" name="content" value="{{ $article->content }}" />
  70. <button type="submit" class="btn btn-primary pull-right editor-submit">提交修改</button>
  71. </div>
  72. </div>
  73. </form>
  74. </div>
  75. </div>
  76. @endsection
  77. @section('script')
  78. <script src="{{ asset('/static/js/summernote/summernote.min.js') }}"></script>
  79. <script src="{{ asset('/static/js/summernote/lang/summernote-zh-CN.min.js') }}"></script>
  80. <script type="text/javascript" src="{{ asset('/static/js/tipask/summernote-ext-attach.js') }}"></script>
  81. <script src="{{ asset('/static/js/select2/js/select2.min.js')}}"></script>
  82. <script type="text/javascript">
  83. $(document).ready(function() {
  84. var category_id = "{{ $article->category_id }}";
  85. $('#article_editor').summernote({
  86. lang: 'zh-CN',
  87. height: 350,
  88. placeholder:'撰写文章',
  89. toolbar: [ {!! config('tipask.summernote.blog') !!} ],
  90. callbacks: {
  91. onChange:function (contents, $editable) {
  92. var code = $(this).summernote("code");
  93. $("#article_editor_content").val(code);
  94. },
  95. onImageUpload: function(files) {
  96. upload_editor_image(files[0],'article_editor');
  97. }
  98. }
  99. });
  100. $("#category_id option").each(function(){
  101. if( $(this).val() == category_id ){
  102. $(this).attr("selected","selected");
  103. }
  104. });
  105. });
  106. </script>
  107. @endsection