index.blade.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. {{--
  2. Вьюха: Список заявок с веб-форм
  3. Создана: 2026-05-07
  4. Контроллер: Admin\LeadController::index()
  5. Переменные: $leads (пагинация), $forms (все формы для фильтра), $formId (текущий фильтр)
  6. --}}
  7. @extends('admin.layout')
  8. @section('title', 'Заявки')
  9. @section('content_header')
  10. <div class="d-flex justify-content-between align-items-center">
  11. <h1 class="m-0">Заявки</h1>
  12. <span class="badge badge-secondary" style="font-size:14px">{{ $leads->total() }}</span>
  13. </div>
  14. @stop
  15. @section('breadcrumb')
  16. <li class="breadcrumb-item"><a href="{{ route('admin.dashboard') }}">Главная</a></li>
  17. <li class="breadcrumb-item active">Заявки</li>
  18. @stop
  19. @section('content')
  20. @if(session('success'))
  21. <div class="alert alert-success alert-dismissible">
  22. <button type="button" class="close" data-dismiss="alert">&times;</button>
  23. {{ session('success') }}
  24. </div>
  25. @endif
  26. {{-- Фильтр по форме --}}
  27. <div class="card card-secondary card-outline mb-3">
  28. <div class="card-body py-2">
  29. <form method="GET" class="d-flex align-items-center gap-2" style="gap:10px">
  30. <label class="mb-0 mr-2 text-muted small">Форма:</label>
  31. <select name="form_id" class="form-control form-control-sm" style="width:auto" onchange="this.form.submit()">
  32. <option value="">Все формы</option>
  33. @foreach($forms as $f)
  34. <option value="{{ $f->id }}" {{ $formId == $f->id ? 'selected' : '' }}>{{ $f->title }}</option>
  35. @endforeach
  36. </select>
  37. @if($formId)
  38. <a href="{{ route('admin.leads.index') }}" class="btn btn-xs btn-default ml-2">Сбросить</a>
  39. @endif
  40. </form>
  41. </div>
  42. </div>
  43. <div class="card card-primary card-outline">
  44. <div class="card-body p-0">
  45. <table class="table table-hover mb-0">
  46. <thead>
  47. <tr>
  48. <th style="width:40px">#</th>
  49. <th style="width:160px">Дата</th>
  50. <th>Форма</th>
  51. <th>Краткое содержание</th>
  52. <th style="width:80px">IP</th>
  53. <th style="width:80px">Статус</th>
  54. <th style="width:80px"></th>
  55. </tr>
  56. </thead>
  57. <tbody>
  58. @forelse($leads as $lead)
  59. <tr class="{{ $lead->read_at ? '' : 'font-weight-bold' }}">
  60. <td class="text-muted">{{ $lead->id }}</td>
  61. <td class="text-muted small">{{ $lead->created_at->format('d.m.Y H:i') }}</td>
  62. <td>
  63. <span class="badge badge-info">{{ $lead->form->title ?? '—' }}</span>
  64. </td>
  65. <td>
  66. {{-- Показываем первые 2 поля заявки --}}
  67. @php $preview = collect($lead->data)->take(2) @endphp
  68. @foreach($preview as $k => $v)
  69. <span class="text-muted small">{{ $k }}:</span> {{ Str::limit($v, 40) }}
  70. @if(!$loop->last) &nbsp;·&nbsp; @endif
  71. @endforeach
  72. </td>
  73. <td class="text-muted small">{{ $lead->ip }}</td>
  74. <td>
  75. @if($lead->read_at)
  76. <span class="badge badge-secondary">Просм.</span>
  77. @else
  78. <span class="badge badge-danger">Новая</span>
  79. @endif
  80. </td>
  81. <td class="text-right">
  82. <a href="{{ route('admin.leads.show', $lead) }}" class="btn btn-xs btn-default" title="Просмотр">
  83. <i class="fas fa-eye"></i>
  84. </a>
  85. <form action="{{ route('admin.leads.destroy', $lead) }}" method="POST" class="d-inline"
  86. onsubmit="return confirm('Удалить заявку #{{ $lead->id }}?')">
  87. @csrf @method('DELETE')
  88. <button type="submit" class="btn btn-xs btn-danger ml-1" title="Удалить">
  89. <i class="fas fa-trash"></i>
  90. </button>
  91. </form>
  92. </td>
  93. </tr>
  94. @empty
  95. <tr>
  96. <td colspan="7" class="text-center text-muted py-4">Заявок пока нет.</td>
  97. </tr>
  98. @endforelse
  99. </tbody>
  100. </table>
  101. </div>
  102. @if($leads->hasPages())
  103. <div class="card-footer">
  104. {{ $leads->links() }}
  105. </div>
  106. @endif
  107. </div>
  108. @stop