CaptchaController.php 721 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace App\Http\Controllers\Account;
  3. use App\Libs\ApiResponse;
  4. use App\Services\Account\CaptchaService;
  5. use Illuminate\Routing\Controller as BaseController;
  6. class CaptchaController extends BaseController
  7. {
  8. use ApiResponse;
  9. protected $captchaService;
  10. public function __construct(
  11. CaptchaService $captchaService
  12. ) {
  13. $this->captchaService = $captchaService;
  14. }
  15. /**
  16. * 获取登录图片验证码(免登录接口)
  17. *
  18. * 返回 { key, image },image 为 data:image/png;base64,... 可直接用于 img src
  19. *
  20. * @return mixed
  21. */
  22. public function getCaptcha()
  23. {
  24. return $this->success($this->captchaService->generate());
  25. }
  26. }