Skip to content

Commit 321338b

Browse files
authored
Merge pull request #27 from lara-zeus/support-type
support png type to render qr in tables
2 parents 6b9538c + faac124 commit 321338b

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

resources/views/download.blade.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ class="flex flex-col gap-2 items-center justify-center"
88
})"
99
>
1010
<div class="flex flex-col justify-center items-center" x-ref="qr">
11-
{{ \LaraZeus\Qr\Facades\Qr::output($data,$options) }}
11+
@if(optional($options)['type'] === 'png')
12+
<img src="data:png;base64,{{ base64_encode(\LaraZeus\Qr\Facades\Qr::output($data,$options)) }}"/>
13+
@else
14+
{{ \LaraZeus\Qr\Facades\Qr::output($data,$options) }}
15+
@endif
1216
</div>
1317

1418
@if($downloadable)

src/Facades/Qr.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public static function getDefaultOptions(): array
2525
{
2626
return [
2727
'size' => '300',
28+
'type' => 'svg',
2829
'margin' => '1',
2930
'color' => 'rgba(74, 74, 74, 1)',
3031
'back_color' => 'rgba(252, 252, 252, 1)',
@@ -258,7 +259,9 @@ public static function output(?string $data = null, ?array $options = null): Htm
258259

259260
return new HtmlString(
260261
// @phpstan-ignore-next-line
261-
$maker->format('svg')->generate((filled($data) ? $data : 'https://'))->toHtml()
262+
$maker->format(optional($options)['type'] ?? 'svg')
263+
->generate((filled($data) ? $data : 'https://'))
264+
->toHtml()
262265
);
263266
}
264267

0 commit comments

Comments
 (0)