38 lines
878 B
PHP
38 lines
878 B
PHP
<?php
|
|
|
|
namespace App\Utils;
|
|
|
|
use EasyWeChat\Kernel\Http\StreamResponse;
|
|
use Storage;
|
|
|
|
class Images
|
|
{
|
|
|
|
/**
|
|
* 获取邀请码
|
|
* @Author:<C.Jason>
|
|
* @Date:2019-05-22T13:20:04+0800
|
|
* @return [type] [description]
|
|
*/
|
|
public static function getUserQrcode($user)
|
|
{
|
|
$app = app('wechat.mini_program');
|
|
|
|
$response = $app->app_code->getUnlimit($user->id, [
|
|
'page' => 'pages/index/index',
|
|
]);
|
|
|
|
$imageFile = 'invites/' . $user->id . '.jpg';
|
|
|
|
if ($response instanceof StreamResponse) {
|
|
$res = Storage::disk(config('admin.upload.disk'))->put($imageFile, $response->getBodyContents());
|
|
$url = Storage::disk(config('admin.upload.disk'))->url($imageFile);
|
|
return $url;
|
|
} else {
|
|
return false;
|
|
// return $response->errmsg;
|
|
}
|
|
}
|
|
|
|
}
|