QRCodeService
in package
QR code generation service for store menus and table ordering.
Tags
Table of Contents
Properties
- $baseUrl : string
Methods
- __construct() : mixed
- generateDataUri() : string
- Generate a QR code and return as a base64 data URI.
- generateMenuQR() : string
- Generate a QR code PNG for a store's menu page.
- generateStoreQR() : string
- Generate a QR code PNG for a store's home/landing page.
- generateTableQR() : string
- Generate a QR code PNG for table ordering.
- getMenuUrl() : string
- Get the URL that a menu QR code points to.
- getStoreUrl() : string
- Get the URL that a store QR code points to.
- getTableUrl() : string
- Get the URL that a table QR code points to.
- generatePng() : string
- Generate a PNG QR code for a given URL.
Properties
$baseUrl
private
string
$baseUrl
Base application URL
Methods
__construct()
public
__construct([string|null $baseUrl = null ]) : mixed
Parameters
- $baseUrl : string|null = null
-
Override base URL (for testing)
generateDataUri()
Generate a QR code and return as a base64 data URI.
public
generateDataUri(string $url[, int $size = 400 ]) : string
Parameters
- $url : string
-
The URL to encode
- $size : int = 400
-
Size in pixels
Return values
string —Data URI string (data:image/png;base64,...)
generateMenuQR()
Generate a QR code PNG for a store's menu page.
public
generateMenuQR(array<string|int, mixed> $business[, int $size = 400 ]) : string
Parameters
- $business : array<string|int, mixed>
-
Business record with 'slug' key
- $size : int = 400
-
QR code size in pixels
Return values
string —PNG binary data
generateStoreQR()
Generate a QR code PNG for a store's home/landing page.
public
generateStoreQR(array<string|int, mixed> $business[, int $size = 400 ]) : string
Parameters
- $business : array<string|int, mixed>
-
Business record with 'slug' key
- $size : int = 400
-
QR code size in pixels
Return values
string —PNG binary data
generateTableQR()
Generate a QR code PNG for table ordering.
public
generateTableQR(array<string|int, mixed> $business, array<string|int, mixed> $table[, int $size = 400 ]) : string
Links to the store menu with the table number pre-filled, so orders placed from this QR are tied to the specific table.
Parameters
- $business : array<string|int, mixed>
-
Business record with 'slug' key
- $table : array<string|int, mixed>
-
Table record with 'id' and 'name' keys
- $size : int = 400
-
QR code size in pixels
Return values
string —PNG binary data
getMenuUrl()
Get the URL that a menu QR code points to.
public
getMenuUrl(array<string|int, mixed> $business) : string
Parameters
- $business : array<string|int, mixed>
-
Business record
Return values
string —Full URL
getStoreUrl()
Get the URL that a store QR code points to.
public
getStoreUrl(array<string|int, mixed> $business) : string
Parameters
- $business : array<string|int, mixed>
-
Business record
Return values
string —Full URL
getTableUrl()
Get the URL that a table QR code points to.
public
getTableUrl(array<string|int, mixed> $business, array<string|int, mixed> $table) : string
Parameters
- $business : array<string|int, mixed>
-
Business record
- $table : array<string|int, mixed>
-
Table record
Return values
string —Full URL
generatePng()
Generate a PNG QR code for a given URL.
private
generatePng(string $url, int $size) : string
Parameters
- $url : string
-
The URL to encode
- $size : int
-
Size in pixels
Return values
string —PNG binary data