mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-14 07:27:47 +00:00
parent
161200df44
commit
8aea83703c
5 changed files with 25 additions and 23 deletions
|
|
@ -45,11 +45,11 @@ class Date extends FiltersProvider
|
||||||
if (count($parts) === 2) {
|
if (count($parts) === 2) {
|
||||||
$before = $date->format($parts[0]);
|
$before = $date->format($parts[0]);
|
||||||
$after = $date->format($parts[1]);
|
$after = $date->format($parts[1]);
|
||||||
return $before . $ordinalDay . $after;
|
|
||||||
|
return $before.$ordinalDay.$after;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback: if no placeholder found, just format normally
|
// Fallback: if no placeholder found, just format normally
|
||||||
return $date->format($phpFormat);
|
return $date->format($phpFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -84,6 +84,7 @@ class ExpressionUtils
|
||||||
if (self::evaluateCondition($condition['left'], $variable, $object)) {
|
if (self::evaluateCondition($condition['left'], $variable, $object)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::evaluateCondition($condition['right'], $variable, $object);
|
return self::evaluateCondition($condition['right'], $variable, $object);
|
||||||
|
|
||||||
case 'comparison':
|
case 'comparison':
|
||||||
|
|
|
||||||
|
|
@ -237,7 +237,7 @@ class Plugin extends Model
|
||||||
// Converts to: {% assign temp_filtered = collection | filter: "key", "value" %}{% for item in temp_filtered %}
|
// Converts to: {% assign temp_filtered = collection | filter: "key", "value" %}{% for item in temp_filtered %}
|
||||||
$template = preg_replace_callback(
|
$template = preg_replace_callback(
|
||||||
'/{%\s*for\s+(\w+)\s+in\s+([^|%}]+)\s*\|\s*([^%}]+)%}/',
|
'/{%\s*for\s+(\w+)\s+in\s+([^|%}]+)\s*\|\s*([^%}]+)%}/',
|
||||||
function ($matches): string {
|
function (array $matches): string {
|
||||||
$variableName = mb_trim($matches[1]);
|
$variableName = mb_trim($matches[1]);
|
||||||
$collection = mb_trim($matches[2]);
|
$collection = mb_trim($matches[2]);
|
||||||
$filter = mb_trim($matches[3]);
|
$filter = mb_trim($matches[3]);
|
||||||
|
|
@ -259,10 +259,11 @@ class Plugin extends Model
|
||||||
// Handle date filter formats: date: "format" or date: 'format'
|
// Handle date filter formats: date: "format" or date: 'format'
|
||||||
$template = preg_replace_callback(
|
$template = preg_replace_callback(
|
||||||
'/date:\s*(["\'])([^"\']+)\1/',
|
'/date:\s*(["\'])([^"\']+)\1/',
|
||||||
function ($matches): string {
|
function (array $matches): string {
|
||||||
$quote = $matches[1];
|
$quote = $matches[1];
|
||||||
$format = $matches[2];
|
$format = $matches[2];
|
||||||
$convertedFormat = \App\Liquid\Utils\ExpressionUtils::strftimeToPhpFormat($format);
|
$convertedFormat = \App\Liquid\Utils\ExpressionUtils::strftimeToPhpFormat($format);
|
||||||
|
|
||||||
return 'date: '.$quote.$convertedFormat.$quote;
|
return 'date: '.$quote.$convertedFormat.$quote;
|
||||||
},
|
},
|
||||||
$template
|
$template
|
||||||
|
|
@ -271,13 +272,14 @@ class Plugin extends Model
|
||||||
// Handle l_date filter formats: l_date: "format" or l_date: 'format'
|
// Handle l_date filter formats: l_date: "format" or l_date: 'format'
|
||||||
$template = preg_replace_callback(
|
$template = preg_replace_callback(
|
||||||
'/l_date:\s*(["\'])([^"\']+)\1/',
|
'/l_date:\s*(["\'])([^"\']+)\1/',
|
||||||
function ($matches): string {
|
function (array $matches): string {
|
||||||
$quote = $matches[1];
|
$quote = $matches[1];
|
||||||
$format = $matches[2];
|
$format = $matches[2];
|
||||||
$convertedFormat = \App\Liquid\Utils\ExpressionUtils::strftimeToPhpFormat($format);
|
$convertedFormat = \App\Liquid\Utils\ExpressionUtils::strftimeToPhpFormat($format);
|
||||||
|
|
||||||
return 'l_date: '.$quote.$convertedFormat.$quote;
|
return 'l_date: '.$quote.$convertedFormat.$quote;
|
||||||
},
|
},
|
||||||
$template
|
(string) $template
|
||||||
);
|
);
|
||||||
|
|
||||||
return $template;
|
return $template;
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ class BatteryLow extends Notification
|
||||||
return (new MailMessage)->markdown('mail.battery-low', ['device' => $this->device]);
|
return (new MailMessage)->markdown('mail.battery-low', ['device' => $this->device]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toWebhook(object $notifiable): \App\Notifications\Messages\WebhookMessage
|
public function toWebhook(object $notifiable): WebhookMessage
|
||||||
{
|
{
|
||||||
return WebhookMessage::create()
|
return WebhookMessage::create()
|
||||||
->data([
|
->data([
|
||||||
|
|
|
||||||
|
|
@ -92,4 +92,3 @@ test('ordinalize filter handles different ordinal suffixes', function (): void {
|
||||||
expect($filter->ordinalize('2025-01-24', '<<ordinal_day>>'))
|
expect($filter->ordinalize('2025-01-24', '<<ordinal_day>>'))
|
||||||
->toBe('24th');
|
->toBe('24th');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue