AdminNotificationLogController.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use App\Http\Controllers\Controller;
  4. use App\Models\NotificationDeliveryLog;
  5. use Illuminate\Http\Request;
  6. class AdminNotificationLogController extends Controller
  7. {
  8. protected array $data = [
  9. 'active' => 'notification_logs',
  10. 'title' => 'Журнал уведомлений',
  11. 'id' => 'notification_logs',
  12. 'header' => [
  13. 'created_at' => 'Дата и время',
  14. 'channel' => 'Канал',
  15. 'user_id' => 'Пользователь',
  16. 'status' => 'Статус',
  17. 'message' => 'Сообщение',
  18. ],
  19. 'searchFields' => [
  20. 'message',
  21. 'error',
  22. ],
  23. ];
  24. public function index(Request $request)
  25. {
  26. session(['gp_notification_logs' => $request->all()]);
  27. $model = new NotificationDeliveryLog();
  28. $this->createFilters($model, 'channel', 'status', 'user_id');
  29. $this->createDateFilters($model, 'created_at');
  30. $q = NotificationDeliveryLog::query()->with('user');
  31. $this->acceptFilters($q, $request);
  32. $this->acceptSearch($q, $request);
  33. $this->setSortAndOrderBy($model, $request);
  34. $this->applyStableSorting($q);
  35. $this->data['logs'] = $q->paginate($this->data['per_page'])->withQueryString();
  36. return view('admin.notifications.log', $this->data);
  37. }
  38. }