AdminNotificationLogController.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. $q->where('channel', '!=', NotificationDeliveryLog::CHANNEL_IN_APP);
  32. $this->acceptFilters($q, $request);
  33. $this->acceptSearch($q, $request);
  34. $this->setSortAndOrderBy($model, $request);
  35. $this->applyStableSorting($q);
  36. $this->data['logs'] = $q->paginate($this->data['per_page'])->withQueryString();
  37. return view('admin.notifications.log', $this->data);
  38. }
  39. }