@@ -85,7 +85,7 @@ public function getBooleanDates() : array
8585 protected function getBooleanDateAttributes () : array
8686 {
8787 return array_intersect_key (
88- $ this ->attributes ,
88+ $ this ->getAttributes () ,
8989 array_flip ($ this ->getBooleanDates ())
9090 );
9191 }
@@ -97,7 +97,7 @@ protected function getBooleanDateAttributes() : array
9797 */
9898 protected function getBooleanDate ($ key ) : bool
9999 {
100- return $ this ->attributes [ $ this -> getBooleanDateField ($ key )] !== null ;
100+ return parent :: getAttribute ( $ this ->getBooleanDateField ($ key )) !== null ;
101101 }
102102
103103 /**
@@ -109,6 +109,10 @@ protected function setBooleanDate(string $key, $value) : void
109109 // Only update the timestamp if the value is true and if it's not yet set
110110 // or if the value is false and we need to unset the field.
111111 if (! $ value || ($ value && $ this ->currentBooleanDateFieldValueIsNotYetSet ($ key ))) {
112+ // Set the value directly on the attributes array, don't use
113+ // setAttribute, and don't receive $200. (\) (°,,,°) (/)
114+ // This allows us to format and set the datetime ourselves,
115+ // and makes using the $dates field optional.
112116 $ this ->attributes [$ this ->getBooleanDateField ($ key )] = $ this ->getNewBooleanDateValue ($ value );
113117 }
114118 }
@@ -130,11 +134,11 @@ protected function hasBooleanDate(string $key) : bool
130134 */
131135 protected function currentBooleanDateFieldValueIsNotYetSet ($ key ) : bool
132136 {
133- if (! array_key_exists ($ this ->getBooleanDateField ($ key ), $ this ->attributes )) {
137+ if (! array_key_exists ($ this ->getBooleanDateField ($ key ), $ this ->getAttributes () )) {
134138 return true ;
135139 }
136140
137- return $ this ->attributes [ $ this -> getBooleanDateField ($ key )] === null ;
141+ return parent :: getAttribute ( $ this ->getBooleanDateField ($ key )) === null ;
138142 }
139143
140144 /**
0 commit comments