feat(devices): 设备列表增加国家筛选项
与访问记录列表实现保持一致: - DeviceController::index() 向视图传入 countries (CfIpCountry::names()) - filtersFrom() 解析 country 参数 (CfIpCountry::normalize,支持 ISO 代码与中文名) - filteredQuery() 按 devices.country 过滤 - 视图在 iOS 版本与钱包之间新增 lay-search 国家下拉框 - 重置按钮 reload where 增加 country: ''
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user