findOrEmpty(); if ($device->isEmpty()) { self::setError('设备不存在'); return false; } // 删除关联的账号 SvAccount::where('device_code', $device->device_code)->select()->each(function ($account) { // 删除AI设置 SvSetting::where('account', $account->account)->select()->delete(); // 删除好友 SvAccountContact::where('account', $account->account)->select()->delete(); $account->delete(); }); $device->delete(); return true; } catch (\Exception $e) { self::setError($e->getMessage()); return false; } } }