info('linkos callback parameters -------->', $request->input()); if ($request->filled('notify_type')) { switch ($request->notify_type) { case 'online_state_change': $this->handleDeviceStateNotify($request); break; } } return response()->json(['code' => 0, 'msg' => 'ok']); } /** * 设备状态通知 */ protected function handleDeviceStateNotify(Request $request): void { foreach ($request->input('data', []) as $item) { if (! isset($item['device_id'])) { continue; } $device = Device::where('sn', $item['device_id'])->first(); if ($device === null) { continue; } if (isset($item['online_state'])) { switch ($item['online_state']) { case 0: $device->forceFill([ 'state' => Device::STATE_OFFLINE, ])->save(); break; case 1: $device->forceFill([ 'state' => Device::STATE_ONLINE, ])->save(); break; } } } } }