39 lines
895 B
PHP
39 lines
895 B
PHP
<?php
|
|
|
|
namespace App\Domains\Captcha\Http\Controllers;
|
|
|
|
use App\Core\Controller;
|
|
use Illuminate\Http\Request;
|
|
use App\Domains\Captcha\Services\CaptchaService;
|
|
|
|
class CaptchaController extends Controller
|
|
{
|
|
/**
|
|
* get CAPTCHA
|
|
*
|
|
* @param Captcha $captcha
|
|
* @param string $config
|
|
* @return \Intervention\Image\ImageManager->response
|
|
*/
|
|
public function getCaptcha(CaptchaService $captcha, $config = 'default')
|
|
{
|
|
if (ob_get_contents()) {
|
|
ob_clean();
|
|
}
|
|
|
|
return $captcha->create($config);
|
|
}
|
|
|
|
/**
|
|
* get CAPTCHA api
|
|
*
|
|
* @param Captcha $captcha
|
|
* @param string $config
|
|
* @return \Intervention\Image\ImageManager->response
|
|
*/
|
|
public function getCaptchaApi(CaptchaService $captcha, $config = 'default')
|
|
{
|
|
return res($captcha->create($config, true), '获取验证码');
|
|
}
|
|
}
|