Skip to content

Commit

Permalink
add default value
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo committed May 13, 2024
1 parent b23cb52 commit 1b16762
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Traits/HasMetaData.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public function metaData(): MorphMany
/**
* Get the meta value of the given key.
*/
public function metaValue(string $key): mixed
public function metaValue(string $key, mixed $default = null): mixed
{
return $this->metaData->firstWhere('key', $key)?->value;
return $this->metaData->firstWhere('key', $key)?->value ?: $default;
}
}

0 comments on commit 1b16762

Please sign in to comment.