diff --git a/src/BladeShortcutsBladeDirectives.php b/src/BladeShortcutsBladeDirectives.php index 2a021cc..faca9ec 100644 --- a/src/BladeShortcutsBladeDirectives.php +++ b/src/BladeShortcutsBladeDirectives.php @@ -74,6 +74,9 @@ public function config(string $expression): string public function date(string $expression): string { $arr = Parser::multipleArgs($expression); + + if(empty($expression)) + $expression = 'null'; if(count($arr) === 2) { switch ($arr[1]) { @@ -82,12 +85,12 @@ public function date(string $expression): string break; default: - return "translatedFormat(__('blade_directives::format.date')); ?>"; + return "translatedFormat(__('blade_directives::format.date')) : \Carbon\Carbon::parse($expression)->translatedFormat(__('blade_directives::format.date')); ?>"; break; } } - return "translatedFormat(__('blade_directives::format.date')); ?>"; + return "translatedFormat(__('blade_directives::format.date')) : \Carbon\Carbon::parse($expression)->translatedFormat(__('blade_directives::format.date')); ?>"; } /** @@ -100,7 +103,7 @@ public function datetime(string $date): string if(empty($date)) $date = 'null'; - return "translatedFormat(__('blade_directives::format.datetime')); ?>"; + return "translatedFormat(__('blade_directives::format.datetime')) : \Carbon\Carbon::parse($date)->translatedFormat(__('blade_directives::format.datetime')); ?>"; } /** @@ -113,7 +116,7 @@ public function year(string $date): string if(empty($date)) $date = 'null'; - return "translatedFormat(__('blade_directives::format.year')); ?>"; + return "translatedFormat(__('blade_directives::format.year')) : \Carbon\Carbon::parse($date)->translatedFormat(__('blade_directives::format.year')); ?>"; } /** @@ -126,7 +129,7 @@ public function month(string $date): string if(empty($date)) $date = 'null'; - return "translatedFormat(__('blade_directives::format.month')); ?>"; + return "translatedFormat(__('blade_directives::format.month')) : \Carbon\Carbon::parse($date)->translatedFormat(__('blade_directives::format.month')); ?>"; } /** @@ -139,7 +142,7 @@ public function day(string $date): string if(empty($date)) $date = 'null'; - return "translatedFormat(__('blade_directives::format.day')); ?>"; + return "translatedFormat(__('blade_directives::format.day')) : \Carbon\Carbon::parse($date)->translatedFormat(__('blade_directives::format.day')); ?>"; } /** @@ -152,7 +155,7 @@ public function time(string $date): string if(empty($date)) $date = 'null'; - return "translatedFormat(__('blade_directives::format.time')); ?>"; + return "translatedFormat(__('blade_directives::format.time')) : \Carbon\Carbon::parse($date)->translatedFormat(__('blade_directives::format.time')); ?>"; } /**