index.blade.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. @extends('layouts.backend')
  2. @section('title', '文章管理')
  3. @section('header')
  4. <h1>
  5. 文章管理
  6. </h1>
  7. @endsection
  8. @section('content')
  9. <div class="row">
  10. <div class="col-xs-12">
  11. @include('backend.alert.success')
  12. <div class="box box-solid">
  13. <div class="box-header">
  14. <form class="form-inline" action="" method="get">
  15. <div class="form-group">
  16. <label for="title">标题</label>&nbsp;
  17. <input name='title' type="text" class="form-control" id="title" placeholder="请输入文章标题">&nbsp;
  18. </div>
  19. <div class="form-group">
  20. <label for="cate_id">分类</label>&nbsp;
  21. @inject('categoryPresenter', 'App\Presenters\CategoryPresenter')
  22. {!! $categoryPresenter->getSelect(0, '请选择', '') !!}
  23. </div>
  24. <button type="submit" class="btn btn-info">搜索</button>
  25. <div class="pull-right">
  26. <a href='{{ route("backend.article.create") }}' class='btn btn-success btn-xs'>
  27. <i class="fa fa-plus"></i>发布文章</a>
  28. </div>
  29. </form>
  30. </div>
  31. <!-- /.box-header -->
  32. <div class="box-body table-responsive no-padding ">
  33. <table class="table table-hover">
  34. <tr>
  35. <th>序号</th>
  36. <th>作者</th>
  37. <th>标题</th>
  38. <th>阅读数</th>
  39. <th>评论数</th>
  40. <th>分类</th>
  41. <th>时间</th>
  42. <th>操作</th>
  43. </tr>
  44. @if ($articles)
  45. @inject('articlePresenter', 'App\Presenters\ArticlePresenter')
  46. <?php $line = 1 ?>
  47. @foreach($articles as $article)
  48. <tr>
  49. <td>{{ $line }}</td>
  50. <td>
  51. @if($article->user)
  52. {{ $article->user->name }}
  53. @endif
  54. </td>
  55. <td>{{ $articlePresenter->formatTitle($article->title) }}</td>
  56. <td>{{ $article->read_count }}</td>
  57. <td>{{ $article->comment_count }}</td>
  58. <td>
  59. @if($article->category)
  60. {{ $article->category->name }}
  61. @endif
  62. </td>
  63. <td>{{ $article->created_at }}</td>
  64. <td>
  65. <a href='{{ route("backend.article.edit", ["id" => $article->id]) }}' class='btn btn-info btn-xs'>
  66. <i class="fa fa-pencil"></i> 修改</a>
  67. <a data-href='{{ route("backend.article.destroy", ["id" => $article->id]) }}'
  68. class='btn btn-danger btn-xs article-delete'><i class="fa fa-trash-o"></i> 删除</a>
  69. </td>
  70. </tr>
  71. <?php $line++ ?>
  72. @endforeach
  73. @endif
  74. </table>
  75. </div>
  76. <!-- /.box-body -->
  77. <div class="box-footer clearfix">
  78. {!! $articles->links() !!}
  79. </div>
  80. </div>
  81. <!-- /.box -->
  82. </div>
  83. </div>
  84. @endsection
  85. @section('javascript')
  86. <script>
  87. $(function() {
  88. $(".article-delete").click(function(){
  89. var url = $(this).attr('data-href');
  90. Moell.ajax.delete(url);
  91. });
  92. });
  93. </script>
  94. @endsection