We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4699642 commit 25dc80bCopy full SHA for 25dc80b
1 file changed
system/Entity.php
@@ -236,13 +236,20 @@ public function syncOriginal()
236
237
/**
238
* Checks a property to see if it has changed since the entity was created.
239
+ * Or, without a parameter, checks if any properties have changed.
240
*
- * @param string $key
241
+ * @param ?string $key
242
243
* @return boolean
244
*/
- public function hasChanged(string $key): bool
245
+ public function hasChanged(string $key = null): bool
246
{
247
+ // If no parameter was given then check all attributes
248
+ if ($key === null)
249
+ {
250
+ return $this->original !== $this->attributes;
251
+ }
252
+
253
// Key doesn't exist in either
254
if (! array_key_exists($key, $this->original) && ! array_key_exists($key, $this->attributes))
255
0 commit comments