blogs.blade.php 4.5 KB

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