后台
This commit is contained in:
@@ -3,19 +3,25 @@
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\captcha\facade\Captcha as thinkCaptcha;
|
||||
use Webman\Captcha\CaptchaBuilder;
|
||||
use support\Request;
|
||||
|
||||
class SysCaptcha extends Model
|
||||
{
|
||||
public static function getCode($uuid)
|
||||
public static function getCode($uuid, $request)
|
||||
{
|
||||
$code_data = thinkCaptcha::create('czg');
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->inline();
|
||||
// 保存至数据库
|
||||
self::create([
|
||||
'uuid' => $uuid,
|
||||
'code' => $code_data['code'],
|
||||
'expire_time' => date('Y-m-d H:i:s', time() + config('captcha.expire_time')),
|
||||
'code' => $builder->getPhrase(),
|
||||
'expire_time' => date('Y-m-d H:i:s', time() + 600),
|
||||
]);
|
||||
return ['img' => $code_data['img']];
|
||||
return ['img' => $img_content];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user