Skip to content

Commit

Permalink
Update HasIdentifier.php
Browse files Browse the repository at this point in the history
  • Loading branch information
toyi authored Jan 28, 2022
1 parent c65ec14 commit c52b604
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/HasIdentifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}

Expand Down Expand Up @@ -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()};
Expand Down

0 comments on commit c52b604

Please sign in to comment.