addres qoshish da api o'zgartirildi

This commit is contained in:
2026-04-23 12:08:47 +05:00
parent 1f2327c2d9
commit 5deccec8ba

View File

@@ -53,13 +53,27 @@ class QrController extends Controller
public static function generateQr($id, $type)
{
// type is 'auto_' or 'estate_'
$cleanType = str_replace('_', '', $type);
$url = route('qr.verify', ['type' => $cleanType, 'id' => $id]);
$dir = 'public/attachments/' . $type . $id;
Storage::makeDirectory($dir);
$qr = QrCode::format('png')->size(200)->generate($url);
Storage::put($dir . '/qr.png', $qr);
try {
$cleanType = str_replace('_', '', $type);
$url = route('qr.verify', ['type' => $cleanType, 'id' => $id]);
$dir = 'public/attachments/' . $type . $id;
$absDir = storage_path('app/' . $dir);
if (!is_dir($absDir)) {
mkdir($absDir, 0755, true);
} else {
chmod($absDir, 0755);
}
$qr = QrCode::format('png')->size(200)->generate($url);
$qrPath = $absDir . '/qr.png';
file_put_contents($qrPath, $qr);
chmod($qrPath, 0644);
} catch (\Exception $e) {
\Illuminate\Support\Facades\Log::error('QR generate failed: ' . $e->getMessage(), [
'id' => $id, 'type' => $type,
]);
}
}
public function qrImage($type, $id)
@@ -67,6 +81,10 @@ class QrController extends Controller
$dbType = $type === 'auto' ? 'auto_' : 'estate_';
$path = storage_path('app/public/attachments/' . $dbType . $id . '/qr.png');
if (!file_exists($path)) {
self::generateQr($id, $dbType);
}
if (!file_exists($path)) {
abort(404);
}