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)
459
459
$ body .= $ this ->class ->field ('casts ' , $ model ->getCasts (), ['before ' => "\n" ]);
460
460
}
461
461
462
- if ($ model ->hasDates ()) {
463
- $ body .= $ this ->class ->field ('dates ' , $ model ->getDates (), ['before ' => "\n" ]);
464
- }
465
-
466
462
if ($ model ->hasHidden () && $ model ->doesNotUseBaseFiles ()) {
467
463
$ body .= $ this ->class ->field ('hidden ' , $ model ->getHidden (), ['before ' => "\n" ]);
468
464
}
Original file line number Diff line number Diff line change @@ -67,11 +67,6 @@ class Model
67
67
*/
68
68
protected $ mutations = [];
69
69
70
- /**
71
- * @var array
72
- */
73
- protected $ dates = [];
74
-
75
70
/**
76
71
* @var array
77
72
*/
@@ -267,12 +262,8 @@ protected function parseColumn(Fluent $column)
267
262
$ cast = 'string ' ;
268
263
}
269
264
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 ])) {
276
267
$ this ->casts [$ propertyName ] = $ cast ;
277
268
}
278
269
@@ -1001,7 +992,12 @@ public function hasDates()
1001
992
*/
1002
993
public function getDates ()
1003
994
{
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
+ );
1005
1001
}
1006
1002
1007
1003
/**
You can’t perform that action at this time.
0 commit comments