index.blade.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. @extends('layouts.admin')
  2. @section('title')
  3. Video Home Page
  4. @stop
  5. @section('content')
  6. <p>Trascina le righe per ordinare gli elementi</p>
  7. <div class="row">
  8. <div class="col-xs-12">
  9. <div class="box">
  10. <div class="box-body">
  11. <div class="box-body table-responsive no-padding">
  12. <table class="table table-striped table-hover">
  13. <thead>
  14. <tr>
  15. <th>Titolo</th>
  16. <th>Piattaforma</th>
  17. <th>Online</th>
  18. <th>Data</th>
  19. <th width="50"></th>
  20. <th width="50"></th>
  21. </tr>
  22. </thead>
  23. <tbody>
  24. @foreach($videos as $video)
  25. <tr class="video_row" data-id="{{$video->id}}" style="cursor:move">
  26. <td><a href="{{ route('videos.edit', array($video->id)) }}" >{{$video->title}}</a></td>
  27. <td>{{$video->type}}</td>
  28. <td>{{$video->online ? 'Si' : 'No'}}</td>
  29. <td>{{date("d/m/Y H:i", strtotime($video->date))}}</td>
  30. <td>
  31. <a href="{{ route('videos.edit', array($video->id)) }}" type="button" class="btn btn-w-m btn-primary">Modifica</a>
  32. </td>
  33. <td>
  34. <form class="form-inline" method="POST" action="{{ route('videos.destroy', $video->id) }}">
  35. @csrf
  36. @method('DELETE')
  37. <button type="submit" class="btn btn-w-m btn-danger" onclick="return confirm('Sei sicuro?')">Elimina</button>
  38. </form>
  39. </td>
  40. </tr>
  41. @endforeach
  42. </table>
  43. </div>
  44. </div>
  45. </div>
  46. <div class="col-xs-2">
  47. <a href="{{ route('videos.create') }}" class="btn btn-success">Aggiungi</a>
  48. </div>
  49. </div>
  50. @stop
  51. @section('extra_css')
  52. <link rel="stylesheet" href="/plugins/datatables/dataTables.bootstrap.css">
  53. <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/1.5.2/css/buttons.dataTables.min.css">
  54. @stop
  55. @section('extra_js')
  56. <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
  57. <script>
  58. $(function () {
  59. $('tbody').sortable({
  60. cursor: "move",
  61. stop: function( ) {
  62. var ids = '';
  63. $(".video_row").each(function()
  64. {
  65. var id = $(this).attr("data-id");
  66. ids += (ids != '' ? ',' : '') + id;
  67. });
  68. $.ajax('/admin/videos/sort/' + ids,
  69. {
  70. success: function (data, status, xhr) {// success callback function
  71. $('p').append(data);
  72. }
  73. });
  74. }
  75. });
  76. });
  77. </script>
  78. @stop