1 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. @extends('layouts.app')
  2. @section('css')
  3. <link href="{!! env('APP_ASSETS') !!}css/dashboard.css" rel="stylesheet" type="text/css">
  4. @endsection
  5. @php
  6. $current_page = strtolower(Route::currentRouteName());
  7. @endphp
  8. @section('content')
  9. <div class="content-wrapper">
  10. <div class="container-full">
  11. <section class="content">
  12. <div class="row">
  13. <div class="col-6"><h3 style="margin-left: 10px">Blogs
  14. </h3></div>
  15. @if(\Illuminate\Support\Facades\Auth::user()->role=="administrator" || \Illuminate\Support\Facades\Auth::user()->role=="admin_user" )
  16. <div class="col-6 text-end"><a href="{!! env('APP_URL') !!}blog/new" class="btn btn-sm btn-danger float-right"><i class="glyphicon glyphicon-plus"></i> Add New </a></div>
  17. @endif
  18. </div>
  19. <div class="row">
  20. <div class="col-xl-12">
  21. <div class="card mb-4">
  22. <div class="card-body">
  23. @if(\Illuminate\Support\Facades\Auth::user()->role=="administrator" || \Illuminate\Support\Facades\Auth::user()->role=="admin_user" )
  24. <div class="table-responsive">
  25. <table class="table table-stripped" id="dataTable" width="100%" cellspacing="0">
  26. <thead>
  27. <tr class="text-uppercase">
  28. <th width="60%">{!! strtoupper($current_page) !!}</th>
  29. <th width="10%">Is Published</th>
  30. <th width="10%">created At</th>
  31. <th width="10%">Action</th>
  32. </tr>
  33. </thead>
  34. <tbody>
  35. @if(isset($blogs) && $blogs->count() > 0)
  36. @foreach($blogs as $blog)
  37. <tr>
  38. <td><span class="fw-bold">{!! $blog->title !!}</span><br />
  39. <span class="text-muted"><small>{!! strip_tags(\Illuminate\Support\Str::substr($blog->content,0,150)) !!}</small></span>
  40. </td>
  41. <td>{!! $blog->is_published !!}</td>
  42. <td>{!! \Carbon\Carbon::parse($blog->created_at)->format('d F, Y H:i') !!}</td>
  43. <td>
  44. <a href="{!! env('APP_URL') !!}blog/edit/{!! $blog->id !!}" class="btn btn-sm btn-primary" data-toggle="tooltip" data-placement="top" title="Edit"><i class="glyphicon glyphicon-edit"></i></a>
  45. <a href="javascript:;" data-id="{!! $blog->id !!}" class="btn btn-sm btn-danger delete-blog" data-toggle="tooltip" data-placement="top" title="Delete"><i class="glyphicon glyphicon-trash"></i></a>
  46. </td>
  47. </tr>
  48. @endforeach
  49. @endif
  50. </tbody>
  51. </table>
  52. </div>
  53. @else
  54. <div class="p-3 text-white bg-danger text-center">You are not authorized for this page</div>
  55. @endif
  56. </div>
  57. </div>
  58. </div>
  59. </div>
  60. </section>
  61. </div>
  62. </div>
  63. @endsection
  64. @section('js')
  65. <script src="{!! env("APP_ASSETS") !!}js/dataTables.editor.min.js"></script>
  66. <script>
  67. var resto_id = 0;
  68. $(function () {
  69. $("body").on("click",".close-modal",function(){
  70. $("#create-translation").modal('hide');
  71. });
  72. $("body").on("click",".delete-blog",function(){
  73. var _id = $(this).data('id');
  74. swal({
  75. title: " Confirm?",
  76. text: "Do you want delete?",
  77. type: "error",
  78. showCancelButton: true,
  79. confirmButtonClass: "btn-danger",
  80. confirmButtonText: " Confirm, delete it!",
  81. cancelButtonText: "No, cancel please!",
  82. closeOnConfirm: true,
  83. closeOnCancel: true
  84. },
  85. function(isConfirm) {
  86. if (isConfirm) {
  87. $.ajax({
  88. url:"{!! env('APP_URL') !!}blog/delete/"+_id,
  89. success:function(){
  90. location.reload();
  91. }
  92. });
  93. }
  94. });
  95. });
  96. $('#dataTable').DataTable({
  97. "bSort": true,
  98. "searching": true,
  99. "paging": true,
  100. "info": true,
  101. language: {
  102. paginate: {
  103. next: '<img src="{!! env("APP_ASSETS") !!}images/icons/next.png">', // or '→'
  104. previous: '<img src="{!! env("APP_ASSETS") !!}images/icons/preivew.png">' // or '←'
  105. }
  106. },
  107. });
  108. })
  109. </script>
  110. @endsection