From 7b7fbc5c13e6863a80bf2770b323b20b50979a77 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 18 Jun 2022 14:25:29 +1000 Subject: [PATCH] Add dedicated :MONTHYEAR reserved keyword --- app/Utils/Helpers.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/Utils/Helpers.php b/app/Utils/Helpers.php index 28cf1adc25..2bd59028e7 100644 --- a/app/Utils/Helpers.php +++ b/app/Utils/Helpers.php @@ -116,6 +116,11 @@ class Helpers $replacements = [ 'literal' => [ + ':MONTHYEAR' => \sprintf( + '%s %s', + Carbon::createFromDate(now()->month)->translatedFormat('F'), + now()->year, + ), ':MONTH' => Carbon::createFromDate(now()->year, now()->month)->translatedFormat('F'), ':YEAR' => now()->year, ':QUARTER' => 'Q' . now()->quarter, @@ -139,6 +144,7 @@ class Helpers ), ], 'raw' => [ + ':MONTHYEAR' => now()->month, ':MONTH' => now()->month, ':YEAR' => now()->year, ':QUARTER' => now()->quarter, @@ -256,6 +262,18 @@ class Helpers $output = \Carbon\Carbon::create()->month($output)->translatedFormat('F'); } + if ($matches->keys()->first() == ':MONTHYEAR') { + + $final_date = now()->addMonths($output-now()->month); + + $output = \sprintf( + '%s %s', + $final_date->translatedFormat('F'), + $final_date->year, + ); + + } + $value = preg_replace( $target, $output, $value, 1 );