ImgServer.php 948 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace App\Servers;
  3. use SimpleSoftwareIO\QrCode\Facades\QrCode;
  4. /**
  5. * 图片OSS管理
  6. */
  7. class ImgServer
  8. {
  9. static private $server = '';
  10. private function __construct()
  11. {
  12. }
  13. /**
  14. * 创建对象
  15. * @return ImgServer
  16. */
  17. static function creatServer()
  18. {
  19. if (empty(self::$server)) {
  20. self::$server = new ImgServer();
  21. }
  22. return self::$server;
  23. }
  24. /**
  25. * 会员code码生成
  26. * @param $address
  27. * @return string
  28. */
  29. function setCoinImg($address)
  30. {
  31. $dir='code/icon/'.date('Ymd').'/';
  32. CommonServer::creatServer()->creatDir($dir);
  33. $fileName=$dir.md5($address).time().'.png';
  34. $code_img = public_path($fileName);
  35. if (!is_file($code_img)) {
  36. file_put_contents($code_img, QrCode::format('png')->size(600)->margin(1)->generate($address));
  37. }
  38. return $code_img;
  39. }
  40. }