12345678910111213141516171819202122232425262728293031 |
- <?php
- namespace App\Http\Controllers;
- use Illuminate\Http\Request;
- class QrCodeController extends Controller
- {
- // 生成二维码
- public function index(Request $request)
- {
- $size = $request->get('size', 430);
- $margin = $request->get('margin', 2);
- $url = $request->get('url');
- list($c1, $c2, $c3) = explode(',', $request->get('color', '0,0,0'));
- list($b1, $b2, $b3) = explode(',', $request->get('bcolor', '255,255,255'));
- $logo = "https://www.fenpeiduixiang.com/favicon.ico";
- $result = \QrCode::format('png')
- ->size($size)
- ->margin($margin)
- ->merge($logo, 0.2, true)
- ->color($c1, $c2, $c3)
- ->backgroundColor($b1, $b2, $b3)
- ->errorCorrection('H')
- ->generate($url);
- return response($result, 200, ['Content-Type' => 'image/png']);
- }
- }
|