index.blade.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <!--
  2. Copyright (C) 2021 Echedey López Romero <elr@disroot.org>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. -->
  14. @extends('layouts.app')
  15. @section('content')
  16. <div class="container">
  17. <div class="row mb-3">
  18. <h1 class="col-12 mb-0 text-center">Books list</h1>
  19. </div>
  20. @if (Session::get('success'))
  21. @php $message = Session::get('success'); @endphp
  22. <div class = "row mb-3">
  23. <span class="col-xl-6 col-lg-8 col-md-10 col-12 mx-auto mb-0 alert alert-success">{{ $message }}</span>
  24. </div>
  25. @endif
  26. <div class="row">
  27. <div class="col-lg-10 col-12 mx-auto">
  28. <div class="container">
  29. <div class="row">
  30. <form class="col-xl-6 col-lg-8 col-md-10 col-12 mx-auto" action="{{ route('books.search') }}" method="POST">
  31. @csrf
  32. <input class="form-control" name="search" type="text" value="{{ isset($oldSearch) ? $oldSearch : '' }}" placeholder="Search by name, authors or editorial" />
  33. </form>
  34. </div>
  35. @if (count($books) !== 0)
  36. <div class="row row-cols-xl-4 row-cols-lg-3 row-cols-md-2 row-cols-1">
  37. @foreach ($books as $book)
  38. <div class="col mt-3 mx-auto">
  39. <div class="card">
  40. <img src="{{ asset($book->image) }}" class="card-img-top" alt="{{ $book->title }}"/>
  41. <div class="card-body">
  42. <div class="card-title">
  43. <div class="container px-0">
  44. <div class="row mb-2">
  45. <span class="col-12 my-auto text-center fs-5">{{ $book->title }}</span>
  46. </div>
  47. <div class="row mb-2">
  48. <span class="col-12 my-auto text-center">{{ $book->authors }}</span>
  49. </div>
  50. <div class="row mb-2">
  51. <span class="col-12 my-auto text-center fs-5">{{ $book->year ? $book->year : 'Undated' }}</span>
  52. </div>
  53. </div>
  54. </div>
  55. <div class="card-text">
  56. <div class="container px-0">
  57. <div class="row">
  58. <div class="col-12">
  59. <div class="d-grid gap-2">
  60. <a href="{{ route('books.show', $book->id) }}" class="btn btn-primary">Show</a>
  61. </div>
  62. </div>
  63. </div>
  64. @if($book->document)
  65. <div class="row mt-2">
  66. <div class="col-12">
  67. <div class="d-grid gap-2">
  68. <a href="{{ $book->document }}" target="_blank" class="btn btn-info">Download</a>
  69. </div>
  70. </div>
  71. </div>
  72. @endif
  73. @Auth
  74. @if (Auth::user()->hasRole('Administrator'))
  75. <div class="row mt-2">
  76. <div class="col-12">
  77. <div class="d-grid gap-2">
  78. <a href="{{ route('books.edit', $book->id) }}" class="btn btn-warning">Edit</a>
  79. </div>
  80. </div>
  81. </div>
  82. <div class="row mt-2">
  83. <form action="{{ route('books.destroy', $book->id) }}" method="POST" class="col-12" onsubmit="return window.confirm('Do you want to remove this book?')">
  84. @csrf
  85. @method('DELETE')
  86. <div class="d-grid gap-2">
  87. <button type="submit" class="btn btn-danger">Delete</button>
  88. </div>
  89. </form>
  90. </div>
  91. @endif
  92. @endauth
  93. </div>
  94. </div>
  95. </div>
  96. </div>
  97. </div>
  98. @endforeach
  99. </div>
  100. <div class="row mt-3">
  101. <div class="d-flex col-12 justify-content-center">
  102. {{ $books->links() }}
  103. </div>
  104. </div>
  105. @else
  106. <div class="row mt-3">
  107. <div class='col-xl-6 col-lg-8 col-md-10 col-12 mx-auto text-center'>
  108. <span>There are not books.</span>
  109. </div>
  110. </div>
  111. @endif
  112. </div>
  113. </div>
  114. </div>
  115. </div>
  116. @endsection