/** * Return a QR code for the asset * * @author [A. Gianotto] [<*****@*****.**>] * @param int $assetId * @since [v1.0] * @return Response */ public function getQrCode($assetId = null) { $settings = Setting::getSettings(); if ($settings->qr_code == '1') { $asset = Asset::find($assetId); $size = Helper::barcodeDimensions($settings->barcode_type); $qr_file = public_path() . '/uploads/barcodes/qr-' . str_slug($asset->asset_tag) . '.png'; if (isset($asset->id, $asset->asset_tag)) { if (file_exists($qr_file)) { $header = ['Content-type' => 'image/png']; return response()->file($qr_file, $header); } else { $barcode = new \Com\Tecnick\Barcode\Barcode(); $barcode_obj = $barcode->getBarcodeObj($settings->barcode_type, route('view/hardware', $asset->id), $size['height'], $size['width'], 'black', array(-2, -2, -2, -2)); file_put_contents($qr_file, $barcode_obj->getPngData()); return response($barcode_obj->getPngData())->header('Content-type', 'image/png'); } } } }
/** * Return a QR code for the asset * * @author [A. Gianotto] [<*****@*****.**>] * @param int $assetId * @since [v1.0] * @return Response */ public function getQrCode($assetId = null) { $settings = Setting::getSettings(); if ($settings->qr_code == '1') { $asset = Asset::find($assetId); $size = Helper::barcodeDimensions($settings->barcode_type); if (isset($asset->id, $asset->asset_tag)) { $barcode = new \Com\Tecnick\Barcode\Barcode(); $barcode_obj = $barcode->getBarcodeObj($settings->barcode_type, route('view/hardware', $asset->id), $size['height'], $size['width'], 'black', array(-2, -2, -2, -2)); return response($barcode_obj->getPngData())->header('Content-type', 'image/png'); } } }