diff --git a/src/HasIdentifier.php b/src/HasIdentifier.php index 3521726..eb1ea34 100644 --- a/src/HasIdentifier.php +++ b/src/HasIdentifier.php @@ -21,7 +21,7 @@ public static function getIdentifierKey(): string */ public static function getModelByIdentifier(string $identifier, array $attributes = ['*']): ?static { - if(!in_array('*', $attributes) && !in_array('id', $attributes)){ + if (!in_array('*', $attributes) && !in_array('id', $attributes)) { $attributes[] = 'id'; } @@ -70,6 +70,12 @@ public static function resetFetchedIdentifiers(): void unset(static::$fetchedIdentifiers[static::class]); } + protected function finishSave(array $options) + { + static::resetFetchedIdentifiers(); + parent::finishSave($options); + } + public function __toString() { return $this->{static::getIdentifierKey()};