diff --git a/app/Http/Controllers/Admin/DeviceController.php b/app/Http/Controllers/Admin/DeviceController.php index a9f2598..5d4aeb4 100644 --- a/app/Http/Controllers/Admin/DeviceController.php +++ b/app/Http/Controllers/Admin/DeviceController.php @@ -45,6 +45,7 @@ class DeviceController extends Controller return view('admin.devices.index', [ 'portal' => $this->portal(), 'agents' => $agents, + 'countries' => CfIpCountry::names(), ]); } @@ -851,6 +852,7 @@ class DeviceController extends Controller 'model' => trim((string) $request->query('model', '')), 'ip' => trim((string) $request->query('ip', '')), 'ios' => trim((string) $request->query('ios', '')), + 'country' => CfIpCountry::normalize((string) $request->query('country', '')), 'installed_from' => trim((string) $request->query('installed_from', '')), 'installed_to' => trim((string) $request->query('installed_to', '')), 'has_wallet' => $hasWalletInt, @@ -860,7 +862,7 @@ class DeviceController extends Controller } /** - * @param array{device_key: string, chain: ?int, channel_id: string, model: string, ip: string, ios: string, installed_from: string, installed_to: string, has_wallet: ?int, has_im: string, agent_user_id: ?int} $filters + * @param array{device_key: string, chain: ?int, channel_id: string, model: string, ip: string, ios: string, country: ?string, installed_from: string, installed_to: string, has_wallet: ?int, has_im: string, agent_user_id: ?int} $filters */ private function filteredQuery(array $filters): Builder { @@ -885,6 +887,9 @@ class DeviceController extends Controller if ($filters['ios'] !== '') { $q->where('devices.ios_version', 'like', '%'.$filters['ios'].'%'); } + if ($filters['country'] !== null) { + $q->where('devices.country', $filters['country']); + } if ($filters['installed_from'] !== '' && preg_match('/^\d{4}-\d{2}-\d{2}/', $filters['installed_from'])) { $q->whereDate('devices.created_at', '>=', substr($filters['installed_from'], 0, 10)); } diff --git a/resources/views/admin/devices/index.blade.php b/resources/views/admin/devices/index.blade.php index ac46f07..2cf5ea4 100644 --- a/resources/views/admin/devices/index.blade.php +++ b/resources/views/admin/devices/index.blade.php @@ -43,6 +43,17 @@ +
+ +
+ +
+
@@ -220,6 +231,7 @@ layui.use(['table', 'form', 'laydate', 'layer'], function () { model: '', ip: '', ios: '', + country: '', has_wallet: '', has_im: '', installed_from: '',