File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,11 @@ class Taxonomy extends Eloquent {
18
18
19
19
public $ timestamps = false ;
20
20
21
+ protected $ appends = [
22
+ 'formatted_add_date ' ,
23
+ 'formatted_mod_date '
24
+ ];
25
+
21
26
/**
22
27
* Get the options for generating the slug.
23
28
*/
@@ -110,4 +115,40 @@ public function delete() {
110
115
111
116
return $ delete ;
112
117
}//end method delete
118
+
119
+ /**
120
+ * get formatted add date
121
+ *
122
+ * @return string
123
+ */
124
+ public function getFormattedAddDateAttribute () {
125
+ if ( ! isset ( $ this ->attributes ['id ' ] ) ) {
126
+ return '' ;
127
+ }
128
+ if ( ! isset ( $ this ->attributes ['add_date ' ] ) ) {
129
+ return '' ;
130
+ }
131
+
132
+ $ format = get_option ('date_format ' ) . ' ' . get_option ('time_format ' );
133
+
134
+ return date_i18n ($ format , strtotime ($ this ->attributes ['add_date ' ]));
135
+ }//end method getFormattedAddDateAttribute
136
+
137
+ /**
138
+ * get formatted mod date
139
+ *
140
+ * @return string
141
+ */
142
+ public function getFormattedModDateAttribute () {
143
+ if ( ! isset ( $ this ->attributes ['id ' ] ) ) {
144
+ return '' ;
145
+ }
146
+ if ( ! $ this ->attributes ['mod_date ' ] ) {
147
+ return '' ;
148
+ }
149
+
150
+ $ format = get_option ('date_format ' ) . ' ' . get_option ('time_format ' );
151
+
152
+ return date_i18n ($ format , strtotime ($ this ->attributes ['mod_date ' ]));
153
+ }//end method getFormattedModDateAttribute
113
154
}//end class Taxonomy
You can’t perform that action at this time.
0 commit comments