File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change 22
33namespace Javaabu \Forms \Views \Components ;
44
5+ use DateTimeInterface ;
6+ use Illuminate \Database \Eloquent \Model ;
7+ use Illuminate \Support \Carbon ;
8+
59class Date extends Input
610{
711 public string $ icon ;
@@ -20,6 +24,7 @@ public function __construct(
2024 string $ type = 'date ' ,
2125 $ model = null ,
2226 $ default = null ,
27+ public string $ dateFormat = '' ,
2328 string $ icon = '' ,
2429 string $ clearIcon = '' ,
2530 string $ clearBtnClass = '' ,
@@ -70,4 +75,13 @@ public function isDateInput(): bool
7075 {
7176 return true ;
7277 }
78+
79+ protected function formatDateTime (Model $ model , string $ key , DateTimeInterface $ date )
80+ {
81+ if (! $ this ->dateFormat ) {
82+ return parent ::formatDateTime ($ model , $ key , $ date );
83+ }
84+
85+ return $ date ->format ($ this ->dateFormat );
86+ }
7387}
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ public function __construct(
1414 string $ label = '' ,
1515 $ model = null ,
1616 $ default = null ,
17+ string $ dateFormat = '' ,
1718 string $ icon = '' ,
1819 string $ clearIcon = '' ,
1920 string $ clearBtnClass = '' ,
@@ -36,6 +37,7 @@ public function __construct(
3637 type: 'datetime ' ,
3738 model: $ model ,
3839 default: $ default ,
40+ dateFormat: $ dateFormat ,
3941 icon: $ icon ,
4042 clearIcon: $ clearIcon ,
4143 clearBtnClass: $ clearBtnClass ,
You can’t perform that action at this time.
0 commit comments