| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- // +----------------------------------------------------------------------
- // | Laravel框架 [ Laravel ]
- // +----------------------------------------------------------------------
- // | 版权所有 2017~2021 Laravel研发中心
- // +----------------------------------------------------------------------
- // | 官方网站: http://www.laravel.cn
- // +----------------------------------------------------------------------
- // | Author: wesmiler <12345678@qq.com>
- // +----------------------------------------------------------------------
- namespace App\Services;
- use App\Models\LinkModel;
- use BaconQrCode\Encoder\QrCode;
- /**
- * 二维码管理-服务类
- * @author wesmiler
- * @since 2020/11/11
- * Class QrcodeService
- * @package App\Services
- */
- class QrcodeService extends BaseService
- {
- protected static $instance = null;
- /**
- * 构造函数
- * @author wesmiler
- * @since 2020/11/11
- * QrcodeService constructor.
- */
- public function __construct()
- {
- }
- /**
- * 静态入口
- * @return QrcodeService|null
- */
- public static function make(){
- if(!self::$instance){
- self::$instance = new QrcodeService();
- }
- return self::$instance;
- }
- /**
- * 生成自定义二维码
- * @param $userId 用户ID
- * @return false|string|\图片地址
- */
- public function makeQrcode($userId){
- $path = 'img/qrcode/U_'.$userId.'_'.base64_encode($userId).'.png';
- QrCode::format('png')->size(100)->encoding('UTF-8')->generate($userId,public_path($path));
- if(file_exists(public_path($path))){
- return get_image_url($path);
- }else{
- return false;
- }
- }
- }
|