index.blade.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. @extends('admin.layouts')
  2. @section('css')
  3. <link href="/assets/global/vendor/bootstrap-table/bootstrap-table.min.css" type="text/css" rel="stylesheet">
  4. @endsection
  5. @section('content')
  6. <div class="page-content container-fluid">
  7. <div class="panel">
  8. <div class="panel-heading">
  9. <h3 class="panel-title">文章列表</h3>
  10. <div class="panel-actions">
  11. <a href="{{route('admin.article.create')}}" class="btn btn-primary"><i class="icon wb-plus"></i>添加文章</a>
  12. </div>
  13. </div>
  14. <div class="panel-body">
  15. <table class="text-md-center" data-toggle="table" data-mobile-responsive="true">
  16. <thead class="thead-default">
  17. <tr>
  18. <th> #</th>
  19. <th> 类型</th>
  20. <th> 标题</th>
  21. <th> 排序</th>
  22. <th> 发布日期</th>
  23. <th> 操作</th>
  24. </tr>
  25. </thead>
  26. <tbody>
  27. @foreach($articles as $article)
  28. <tr>
  29. <td> {{$article->id}} </td>
  30. @if ($article->type === 1)
  31. <td> 文章</td>
  32. @elseif ($article->type === 2)
  33. <td> 公告</td>
  34. @elseif ($article->type === 3)
  35. <td> 购买说明</td>
  36. @elseif ($article->type === 4)
  37. <td> 使用教程</td>
  38. @else
  39. <td> 未知</td>
  40. @endif
  41. <td>
  42. <a href="{{route('admin.article.show',$article->id)}}" target="_blank"> {{Str::limit($article->title, 80)}} </a>
  43. </td>
  44. <td> {{$article->sort}} </td>
  45. <td> {{$article->created_at}} </td>
  46. <td>
  47. <div class="btn-group">
  48. <a href="{{route('admin.article.edit',['article'=>$article->id, 'page'=>Request::input('page')])}}" class="btn btn-outline-primary">
  49. <i class="icon wb-edit"></i></a>
  50. <button class="btn btn-outline-danger" onclick="delArticle('{{route('admin.article.destroy',$article->id)}}')">
  51. <i class="icon wb-close"></i></button>
  52. </div>
  53. </td>
  54. </tr>
  55. @endforeach
  56. </tbody>
  57. </table>
  58. </div>
  59. <div class="panel-footer">
  60. <div class="row">
  61. <div class="col-sm-4">
  62. 共 <code>{{$articles->total()}}</code> 篇文章
  63. </div>
  64. <div class="col-sm-8">
  65. <nav class="Page navigation float-right">
  66. {{$articles->links()}}
  67. </nav>
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. @endsection
  74. @section('script')
  75. <script src="/assets/global/vendor/bootstrap-table/bootstrap-table.min.js" type="text/javascript"></script>
  76. <script src="/assets/global/vendor/bootstrap-table/extensions/mobile/bootstrap-table-mobile.min.js" type="text/javascript"></script>
  77. <script type="text/javascript">
  78. // 删除文章
  79. function delArticle(url) {
  80. swal.fire({
  81. title: '确定删除文章?',
  82. type: 'question',
  83. showCancelButton: true,
  84. cancelButtonText: '{{trans('home.ticket_close')}}',
  85. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  86. }).then((result) => {
  87. if (result.value) {
  88. $.ajax({
  89. method: 'DELETE',
  90. url: url,
  91. data: {_token: '{{csrf_token()}}'},
  92. dataType: 'json',
  93. success: function(ret) {
  94. if (ret.status === 'success') {
  95. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  96. }
  97. else {
  98. swal.fire({title: ret.message, type: 'error'}).then(() => window.location.reload());
  99. }
  100. },
  101. });
  102. }
  103. });
  104. }
  105. </script>
  106. @endsection