dataLists(new DeviceLists()); } public function detail() { $id = (int)$this->request->get('id', 0); if ($id <= 0) return $this->fail('参数错误'); $info = UserDevice::findOrEmpty($id)->toArray(); return $this->data($info); } public function delete() { $id = (int)$this->request->post('id', 0); if ($id <= 0) return $this->fail('参数错误'); UserDevice::destroy($id); return $this->success('删除成功', [], 1, 1); } /** * 设备统计概览 */ public function stats() { $total = UserDevice::count(); $platforms = UserDevice::field('platform, COUNT(*) as count') ->group('platform') ->select() ->toArray(); $today = strtotime(date('Y-m-d')); $todayActive = UserDevice::where('last_at', '>=', $today)->count(); $todayNew = UserDevice::where('first_at', '>=', $today)->count(); return $this->data([ 'total' => $total, 'today_active' => $todayActive, 'today_new' => $todayNew, 'platforms' => $platforms, ]); } }