42 lines
1012 B
PHP
42 lines
1012 B
PHP
<?php
|
|
|
|
namespace app\controller;
|
|
use Webman\Captcha\CaptchaBuilder;
|
|
|
|
use support\Request;
|
|
|
|
class IndexController
|
|
{
|
|
public function index(Request $request)
|
|
{
|
|
return response('hello webman');
|
|
}
|
|
|
|
public function login(Request $request)
|
|
{
|
|
return view('login');
|
|
}
|
|
public function check(Request $request)
|
|
{
|
|
return view('login');
|
|
}
|
|
public function code(Request $request)
|
|
{
|
|
// 初始化验证码类
|
|
$builder = new CaptchaBuilder;
|
|
// 生成验证码
|
|
$builder->build();
|
|
// 将验证码的值存储到session中
|
|
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
|
// 获得验证码图片二进制数据
|
|
$img_content = $builder->get();
|
|
// 输出验证码二进制数据
|
|
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
|
}
|
|
public function json(Request $request)
|
|
{
|
|
return json(['code' => 0, 'msg' => 'ok']);
|
|
}
|
|
|
|
}
|