QR-Codes-UI zu Einladungen umgebaut mit PDF-Export und Druckanzeige + Customizer
This commit is contained in:
@@ -7,6 +7,7 @@ use App\Support\JoinTokenLayoutRegistry;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use SimpleSoftwareIO\QrCode\Facades\QrCode;
|
||||
|
||||
class EventJoinTokenResource extends JsonResource
|
||||
{
|
||||
@@ -40,13 +41,34 @@ class EventJoinTokenResource extends JsonResource
|
||||
}
|
||||
|
||||
$plainToken = $this->resource->plain_token ?? $this->token;
|
||||
$qrCodeUrl = $plainToken ? url('/e/'.$plainToken) : null;
|
||||
$qrCodeDataUrl = null;
|
||||
|
||||
if ($qrCodeUrl) {
|
||||
try {
|
||||
$svg = QrCode::format('svg')
|
||||
->size(360)
|
||||
->margin(1)
|
||||
->errorCorrection('M')
|
||||
->generate($qrCodeUrl);
|
||||
|
||||
$svgString = (string) $svg;
|
||||
|
||||
if ($svgString !== '') {
|
||||
$qrCodeDataUrl = 'data:image/svg+xml;base64,'.base64_encode($svgString);
|
||||
}
|
||||
} catch (\Throwable $exception) {
|
||||
report($exception);
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'label' => $this->label,
|
||||
'token' => $plainToken,
|
||||
'token_preview' => $this->token_preview,
|
||||
'url' => $plainToken ? url('/e/'.$plainToken) : null,
|
||||
'url' => $qrCodeUrl,
|
||||
'qr_code_data_url' => $qrCodeDataUrl,
|
||||
'usage_limit' => $this->usage_limit,
|
||||
'usage_count' => $this->usage_count,
|
||||
'expires_at' => optional($this->expires_at)->toIso8601String(),
|
||||
|
||||
Reference in New Issue
Block a user