File tree Expand file tree Collapse file tree 2 files changed +8
-16
lines changed Expand file tree Collapse file tree 2 files changed +8
-16
lines changed Original file line number Diff line number Diff line change @@ -459,10 +459,6 @@ protected function body(Model $model)
459459 $ body .= $ this ->class ->field ('casts ' , $ model ->getCasts (), ['before ' => "\n" ]);
460460 }
461461
462- if ($ model ->hasDates ()) {
463- $ body .= $ this ->class ->field ('dates ' , $ model ->getDates (), ['before ' => "\n" ]);
464- }
465-
466462 if ($ model ->hasHidden () && $ model ->doesNotUseBaseFiles ()) {
467463 $ body .= $ this ->class ->field ('hidden ' , $ model ->getHidden (), ['before ' => "\n" ]);
468464 }
Original file line number Diff line number Diff line change @@ -67,11 +67,6 @@ class Model
6767 */
6868 protected $ mutations = [];
6969
70- /**
71- * @var array
72- */
73- protected $ dates = [];
74-
7570 /**
7671 * @var array
7772 */
@@ -267,12 +262,8 @@ protected function parseColumn(Fluent $column)
267262 $ cast = 'string ' ;
268263 }
269264
270- // Track dates
271- if ($ cast == 'date ' ) {
272- $ this ->dates [] = $ propertyName ;
273- }
274- // Track attribute casts
275- elseif ($ cast != 'string ' ) {
265+ // Track attribute casts, ignoring timestamps
266+ if ($ cast != 'string ' && !in_array ($ propertyName , [$ this ->CREATED_AT , $ this ->UPDATED_AT ])) {
276267 $ this ->casts [$ propertyName ] = $ cast ;
277268 }
278269
@@ -1001,7 +992,12 @@ public function hasDates()
1001992 */
1002993 public function getDates ()
1003994 {
1004- return array_diff ($ this ->dates , [$ this ->CREATED_AT , $ this ->UPDATED_AT ]);
995+ return array_diff (
996+ array_filter ($ this ->casts , function (string $ cast ) {
997+ return $ cast === 'date ' ;
998+ }),
999+ [$ this ->CREATED_AT , $ this ->UPDATED_AT ]
1000+ );
10051001 }
10061002
10071003 /**
You can’t perform that action at this time.
0 commit comments