index.blade.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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">Categories 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('categories.search') }}" method="POST">
  31. @csrf
  32. <input class="form-control" name="search" type="text" value="{{ isset($oldSearch) ? $oldSearch : '' }}" placeholder="Search by name"/>
  33. </form>
  34. </div>
  35. @if (count($categories) !== 0)
  36. @foreach ($categories as $category)
  37. <div class="row mt-3">
  38. <div class="col-xl-7 col-lg-10 col-12 mx-auto p-3 border border-secondary rounded">
  39. <div class="container px-0">
  40. <div class="row mb-3">
  41. <span class="col-12 text-center fs-4">{{ $category->name }}</span>
  42. </div>
  43. <div class="row">
  44. @Auth
  45. @if (Auth::user()->hasRole('Administrator'))
  46. <div class="col-md-4 col-12 pe-md-2">
  47. <div class="d-grid gap-2">
  48. <a href="{{ route('categories.show', $category->id) }}" class="btn btn-primary">Show</a>
  49. </div>
  50. </div>
  51. <div class="col-md-4 col-12 mt-md-0 mt-2 ps-md-2 pe-md-2">
  52. <div class="d-grid gap-2">
  53. <a href="{{ route('categories.edit', $category->id) }}" class="btn btn-warning">Edit</a>
  54. </div>
  55. </div>
  56. <form action="{{ route('categories.destroy', $category->id) }}" method="POST" class="col-md-4 col-12 mt-md-0 mt-2 ps-md-2" onsubmit="return window.confirm('Do you want to delete this category?')">
  57. @csrf
  58. @method('DELETE')
  59. <div class="d-grid gap-2">
  60. <button type="submit" class="btn btn-danger">Delete</button>
  61. </div>
  62. </form>
  63. @else
  64. <div class="col-md-4 col-12 mx-auto">
  65. <div class="d-grid gap-2">
  66. <a href="{{ route('categories.show', $category->id) }}" class="btn btn-primary">Show</a>
  67. </div>
  68. </div>
  69. @endif
  70. @else
  71. <div class="col-md-4 col-12 mx-auto">
  72. <div class="d-grid gap-2">
  73. <a href="{{ route('categories.show', $category->id) }}" class="btn btn-primary">Show</a>
  74. </div>
  75. </div>
  76. @endauth
  77. </div>
  78. </div>
  79. </div>
  80. </div>
  81. @endforeach
  82. <div class="row mt-3">
  83. <div class="d-flex col-12 justify-content-center">
  84. {{ $categories->links() }}
  85. </div>
  86. </div>
  87. @else
  88. <div class="row mt-3">
  89. <div class='col-xl-6 col-lg-8 col-md-10 col-12 mx-auto text-center'>
  90. <span>There are not categories.</span>
  91. </div>
  92. </div>
  93. @endif
  94. </div>
  95. </div>
  96. </div>
  97. </div>
  98. @endsection