belongsTo("app\\{$module}\\model\\User"); } /** * 获取一个可用的formid * @param $userId * @return array|false|\PDOStatement|string|\think\Model|static */ public static function getAvailable($userId) { return (new static)->where([ 'user_id' => $userId, 'is_used' => 0, 'expiry_time' => ['>=', time()] ])->order(['create_time' => 'asc'])->find(); } /** * 标记为已使用 * @param $id * @return Formid */ public static function setIsUsed($id) { return static::update(['is_used' => 1], compact('id')); } }