data.blade.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. @extends('layouts.app')
  2. @section('title', 'Просмотр данных')
  3. @section('content')
  4. <div class="container mx-auto px-4 py-8">
  5. <div class="mb-6">
  6. <div class="flex justify-between items-center">
  7. <h4 class="text-2xl font-bold text-gray-800">Все отправленные данные</h4>
  8. <div class="flex space-x-2">
  9. <a href="{{ route('form.show') }}"
  10. class="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 transition">
  11. Добавить новую
  12. </a>
  13. <a href="{{ route('api.form-data.statistics') }}"
  14. target="_blank"
  15. class="px-4 py-2 bg-green-500 text-white rounded hover:bg-green-600 transition">
  16. API Статистика
  17. </a>
  18. </div>
  19. </div>
  20. <!-- Фильтры -->
  21. <div class="mt-4 bg-white rounded-lg shadow p-4">
  22. <form method="GET" action="{{ route('data.show') }}" class="flex flex-wrap gap-4">
  23. <div>
  24. <label class="block text-sm font-medium text-gray-700 mb-1">Пол</label>
  25. <select name="gender" class="px-3 py-2 border border-gray-300 rounded">
  26. <option value="">Все</option>
  27. <option value="male" {{ request('gender') == 'male' ? 'selected' : '' }}>Мужской</option>
  28. <option value="female" {{ request('gender') == 'female' ? 'selected' : '' }}>Женский</option>
  29. </select>
  30. </div>
  31. <div>
  32. <label class="block text-sm font-medium text-gray-700 mb-1">Категория</label>
  33. <select name="category_id" class="px-3 py-2 border border-gray-300 rounded">
  34. <option value="">Все категории</option>
  35. @foreach($categories as $category)
  36. <option value="{{ $category->id }}" {{ request('category_id') == $category->id ? 'selected' : '' }}>
  37. {{ $category->name }}
  38. </option>
  39. @endforeach
  40. </select>
  41. </div>
  42. <div class="flex items-end">
  43. <label class="inline-flex items-center mt-2">
  44. <input type="checkbox"
  45. name="today"
  46. value="1"
  47. {{ request('today') ? 'checked' : '' }}
  48. class="h-4 w-4 text-blue-600">
  49. <span class="ml-2 text-gray-700">За сегодня</span>
  50. </label>
  51. </div>
  52. <div class="flex items-end space-x-2">
  53. <button type="submit"
  54. class="px-4 py-2 bg-gray-600 text-white rounded hover:bg-gray-700 transition">
  55. Фильтровать
  56. </button>
  57. <a href="{{ route('data.show') }}"
  58. class="px-4 py-2 border border-gray-300 text-gray-700 rounded hover:bg-gray-50 transition">
  59. Сбросить
  60. </a>
  61. </div>
  62. </form>
  63. </div>
  64. </div>
  65. @if($data->isEmpty())
  66. <div class="bg-white rounded-lg shadow-md p-8 text-center">
  67. <p class="text-gray-600 text-lg mb-4">Данные отсутствуют.</p>
  68. <a href="{{ route('form.show') }}"
  69. class="px-6 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 transition">
  70. Отправьте форму
  71. </a> чтобы добавить данные.
  72. </div>
  73. @else
  74. <div class="bg-white rounded-lg shadow-md overflow-hidden">
  75. <div class="overflow-x-auto">
  76. <table class="min-w-full divide-y divide-gray-200">
  77. <thead class="bg-gray-50">
  78. <tr>
  79. <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">ID</th>
  80. <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Имя</th>
  81. <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Email</th>
  82. <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Телефон</th>
  83. <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Пол</th>
  84. <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Категория</th>
  85. <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Сообщение</th>
  86. <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Дата</th>
  87. <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Действия</th>
  88. </tr>
  89. </thead>
  90. <tbody class="bg-white divide-y divide-gray-200">
  91. @foreach($data as $item)
  92. <tr class="hover:bg-gray-50 transition">
  93. <td class="px-6 py-4 whitespace-nowrap">
  94. <small class="text-gray-500">{{ substr($item->uuid, 0, 8) }}...</small>
  95. </td>
  96. <td class="px-6 py-4 whitespace-nowrap">
  97. <a href="{{ route('form-data.show', $item->id) }}"
  98. class="text-blue-600 hover:text-blue-800 font-medium">
  99. {{ $item->name }}
  100. </a>
  101. </td>
  102. <td class="px-6 py-4 whitespace-nowrap">{{ $item->email }}</td>
  103. <td class="px-6 py-4 whitespace-nowrap">{{ $item->phone }}</td>
  104. <td class="px-6 py-4 whitespace-nowrap">
  105. <span class="px-2 py-1 text-xs rounded-full {{ $item->gender ? 'bg-blue-100 text-blue-800' : 'bg-pink-100 text-pink-800' }}">
  106. {{ $item->gender ? 'Male' : 'Female' }}
  107. </span>
  108. </td>
  109. <td class="px-6 py-4 whitespace-nowrap">
  110. @if($item->category)
  111. <span class="px-2 py-1 bg-gray-100 text-gray-800 text-xs rounded">
  112. {{ $item->category->name }}
  113. </span>
  114. @else
  115. <span class="text-gray-400">—</span>
  116. @endif
  117. </td>
  118. <td class="px-6 py-4">
  119. <div class="max-w-xs truncate">
  120. {{ Str::limit($item->message, 50) }}
  121. </div>
  122. </td>
  123. <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
  124. {{ $item->submitted_at->timezone('Asia/Irkutsk')->format('d.m.Y H:i') }}
  125. </td>
  126. <td class="px-6 py-4 whitespace-nowrap text-sm">
  127. <div class="flex space-x-2">
  128. <a href="{{ route('form-data.show', $item->id) }}"
  129. class="text-blue-600 hover:text-blue-800" title="Просмотр">
  130. 👁️
  131. </a>
  132. <a href="{{ route('form-data.edit', $item->id) }}"
  133. class="text-yellow-600 hover:text-yellow-800" title="Редактировать">
  134. ✏️
  135. </a>
  136. <form action="{{ route('form-data.destroy', $item->id) }}"
  137. method="POST"
  138. class="inline"
  139. onsubmit="return confirm('Удалить эту запись?')">
  140. @csrf
  141. @method('DELETE')
  142. <button type="submit"
  143. class="text-red-600 hover:text-red-800"
  144. title="Удалить">
  145. 🗑️
  146. </button>
  147. </form>
  148. </div>
  149. </td>
  150. </tr>
  151. @endforeach
  152. </tbody>
  153. </table>
  154. </div>
  155. <div class="px-6 py-4 border-t border-gray-200">
  156. {{ $data->onEachSide(1)->links('pagination::simple-bootstrap-5') }}
  157. </div>
  158. </div>
  159. <div class="mt-6 grid grid-cols-1 md:grid-cols-4 gap-4">
  160. <div class="bg-white rounded-lg shadow p-4">
  161. <div class="text-sm text-gray-500">Всего записей</div>
  162. <div class="text-2xl font-bold text-gray-800">{{ $data->total() }}</div>
  163. </div>
  164. <div class="bg-white rounded-lg shadow p-4">
  165. <div class="text-sm text-gray-500">Мужчины</div>
  166. <div class="text-2xl font-bold text-blue-600">
  167. {{ \App\Models\FormData::male()->count() }}
  168. </div>
  169. </div>
  170. <div class="bg-white rounded-lg shadow p-4">
  171. <div class="text-sm text-gray-500">Женщины</div>
  172. <div class="text-2xl font-bold text-pink-600">
  173. {{ \App\Models\FormData::female()->count() }}
  174. </div>
  175. </div>
  176. <div class="bg-white rounded-lg shadow p-4">
  177. <div class="text-sm text-gray-500">Сегодня</div>
  178. <div class="text-2xl font-bold text-green-600">
  179. {{ \App\Models\FormData::today()->count() }}
  180. </div>
  181. </div>
  182. </div>
  183. @endif
  184. <div class="mt-8 bg-gray-50 rounded-lg p-6">
  185. <h5 class="text-lg font-semibold text-gray-800 mb-4">API Endpoints</h5>
  186. <div class="space-y-2">
  187. <div class="flex items-center">
  188. <span class="bg-blue-100 text-blue-800 text-xs font-medium px-2 py-1 rounded mr-2">GET</span>
  189. <code class="text-sm">/api/v1/form-data</code>
  190. <span class="ml-2 text-gray-600">— Список данных</span>
  191. </div>
  192. <div class="flex items-center">
  193. <span class="bg-green-100 text-green-800 text-xs font-medium px-2 py-1 rounded mr-2">POST</span>
  194. <code class="text-sm">/api/v1/form-data</code>
  195. <span class="ml-2 text-gray-600">— Создание записи</span>
  196. </div>
  197. <div class="flex items-center">
  198. <span class="bg-yellow-100 text-yellow-800 text-xs font-medium px-2 py-1 rounded mr-2">GET</span>
  199. <code class="text-sm">/api/v1/form-data/statistics</code>
  200. <span class="ml-2 text-gray-600">— Статистика</span>
  201. </div>
  202. </div>
  203. </div>
  204. </div>
  205. @endsection