show.blade.php 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <!--
  2. Copyright (C) 2022 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">Category information</h1>
  19. </div>
  20. <div class="row">
  21. <div class="col-lg-10 col-12 mx-auto">
  22. <div class="container">
  23. <div class="row mb-3">
  24. <span class="col-xl-4 col-12 my-xl-auto mb-2">Name</span>
  25. <span class="col-xl-8 col-12 mb-xl-0 mb-2">{{ $category->name }}</span>
  26. </div>
  27. <div class="row mb-3">
  28. <span class="col-xl-4 col-12 my-xl-auto mb-2">Description</span>
  29. <span class="col-xl-8 col-12 mb-xl-0 mb-2">{{ $category->description ? $category->description : 'No description' }}</span>
  30. </div>
  31. <div class="row">
  32. <form class="col-xl-6 col-lg-8 col-md-10 col-12 mx-auto" action="{{ route('categories.searchBooks', $category->id) }}" method="POST">
  33. @csrf
  34. <input class="form-control" name="search" type="text" value="{{ isset($oldSearch) ? $oldSearch : '' }}" placeholder="Search by book name, authors or editorial"/>
  35. </form>
  36. </div>
  37. @if (count($books) !== 0)
  38. <div class="row row-cols-lg-3 row-cols-md-2 row-cols-1">
  39. @foreach ($books as $book)
  40. <div class="col mt-3 mx-auto">
  41. <div class="card">
  42. <img src="{{ asset($book->image) }}" class="card-img-top" alt="{{ $book->title }}"/>
  43. <div class="card-body">
  44. <div class="card-title">
  45. <div class="container px-0">
  46. <div class="row mb-2">
  47. <span class="col-12 my-auto text-center fs-5">{{ $book->title }}</span>
  48. </div>
  49. <div class="row mb-2">
  50. <span class="col-12 my-auto text-center">{{ $book->authors }}</span>
  51. </div>
  52. <div class="row mb-2">
  53. <span class="col-12 my-auto text-center fs-5">{{ $book->year ? $book->year : 'Undated' }}</span>
  54. </div>
  55. </div>
  56. </div>
  57. <div class="card-text">
  58. <div class="container px-0">
  59. <div class="row">
  60. <div class="col-12">
  61. <div class="d-grid gap-2">
  62. <a href="{{ route('books.show', $book->id) }}" class="btn btn-primary">Show</a>
  63. </div>
  64. </div>
  65. </div>
  66. @if($book->document)
  67. <div class="row mt-2">
  68. <div class="col-12">
  69. <div class="d-grid gap-2">
  70. <a href="{{ $book->document }}" target="_blank" class="btn btn-info">Download</a>
  71. </div>
  72. </div>
  73. </div>
  74. @endif
  75. @Auth
  76. @if (Auth::user()->hasRole('Administrator'))
  77. <div class="row mt-2">
  78. <div class="col-12">
  79. <div class="d-grid gap-2">
  80. <a href="{{ route('books.edit', $book->id) }}" class="btn btn-warning">Edit</a>
  81. </div>
  82. </div>
  83. </div>
  84. <div class="row mt-2">
  85. <form action="{{ route('books.destroy', $book->id) }}" method="POST" class="col-12" onsubmit="return window.confirm('Do you want to remove this book?')">
  86. @csrf
  87. @method('DELETE')
  88. <div class="d-grid gap-2">
  89. <button type="submit" class="btn btn-danger">Delete</button>
  90. </div>
  91. </form>
  92. </div>
  93. @endif
  94. @endauth
  95. </div>
  96. </div>
  97. </div>
  98. </div>
  99. </div>
  100. @endforeach
  101. </div>
  102. <div class="row mt-3">
  103. <div class="d-flex col-12 justify-content-center">
  104. {{ $books->links() }}
  105. </div>
  106. </div>
  107. @else
  108. <div class="row mt-3">
  109. <div class='col-xl-6 col-lg-8 col-md-10 col-12 mx-auto text-center'>
  110. <span>There are not books in this category.</span>
  111. </div>
  112. </div>
  113. @endif
  114. </div>
  115. </div>
  116. </div>
  117. </div>
  118. @endsection