mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-03-14 20:33:40 +00:00
add trmnl property to Balde renderContext to follow up liquid renderContex changes
Some checks failed
tests / ci (push) Has been cancelled
Some checks failed
tests / ci (push) Has been cancelled
This commit is contained in:
parent
3abc67ff67
commit
433bda9639
1 changed files with 35 additions and 0 deletions
|
|
@ -575,10 +575,45 @@ class Plugin extends Model
|
||||||
$renderedContent = $template->render($liquidContext);
|
$renderedContent = $template->render($liquidContext);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// Get timezone from user or fall back to app timezone
|
||||||
|
$timezone = $this->user->timezone ?? config('app.timezone');
|
||||||
|
|
||||||
|
// Calculate UTC offset in seconds
|
||||||
|
$utcOffset = (string) Carbon::now($timezone)->getOffset();
|
||||||
|
|
||||||
$renderedContent = Blade::render($markup, [
|
$renderedContent = Blade::render($markup, [
|
||||||
'size' => $size,
|
'size' => $size,
|
||||||
'data' => $this->data_payload,
|
'data' => $this->data_payload,
|
||||||
'config' => $this->configuration ?? [],
|
'config' => $this->configuration ?? [],
|
||||||
|
'trmnl' => [
|
||||||
|
'system' => [
|
||||||
|
'timestamp_utc' => now()->utc()->timestamp,
|
||||||
|
],
|
||||||
|
'user' => [
|
||||||
|
'utc_offset' => $utcOffset,
|
||||||
|
'name' => $this->user->name ?? 'Unknown User',
|
||||||
|
'locale' => 'en',
|
||||||
|
'time_zone_iana' => $timezone,
|
||||||
|
],
|
||||||
|
'device' => [
|
||||||
|
'friendly_id' => $device?->friendly_id,
|
||||||
|
'percent_charged' => $device?->battery_percent,
|
||||||
|
'wifi_strength' => $device?->wifi_strength,
|
||||||
|
'height' => $device?->height,
|
||||||
|
'width' => $device?->width,
|
||||||
|
],
|
||||||
|
'plugin_settings' => [
|
||||||
|
'instance_name' => $this->name,
|
||||||
|
'strategy' => $this->data_strategy,
|
||||||
|
'dark_mode' => $this->dark_mode ? 'yes' : 'no',
|
||||||
|
'no_screen_padding' => $this->no_bleed ? 'yes' : 'no',
|
||||||
|
'polling_headers' => $this->polling_header,
|
||||||
|
'polling_url' => $this->polling_url,
|
||||||
|
'custom_fields_values' => [
|
||||||
|
...(is_array($this->configuration) ? $this->configuration : []),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue