32 lines
804 B
PHP
32 lines
804 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Storage;
|
|
use SimpleSoftwareIO\QrCode\Facades\QrCode;
|
|
|
|
class QrController extends Controller
|
|
{
|
|
public function show($content)
|
|
{
|
|
return view('qr.show', compact('content'));
|
|
}
|
|
|
|
public function reGenerate($id, $type)
|
|
{
|
|
self::generateQr($id, $type);
|
|
return redirect()->back();
|
|
}
|
|
|
|
public static function generateQr($id, $type)
|
|
{
|
|
// type is 'auto_' or 'estate_'
|
|
$url = url(($type === 'auto_' ? 'auto' : 'estate') . '/show/' . $id);
|
|
$dir = 'public/attachments/' . $type . $id;
|
|
Storage::makeDirectory($dir);
|
|
$qr = QrCode::format('png')->size(200)->generate($url);
|
|
Storage::put($dir . '/qr.png', $qr);
|
|
}
|
|
}
|