where('last_time', 'GT', time())->where('is_use', 0) ->where('code', $code)->count(); self::where('last_time', 'LT', time())->delete(); return $res; } public static function setCodeInvalid($phone, $code) { self::where('tel', $phone)->where('last_time', 'GT', time())->where('is_use', 0) ->where('code', $code)->update(['is_use' => 1]); } }