diff --git a/src/Traits/HasMetaData.php b/src/Traits/HasMetaData.php index 119bf7c0..32a46d7d 100644 --- a/src/Traits/HasMetaData.php +++ b/src/Traits/HasMetaData.php @@ -14,4 +14,12 @@ public function metaData(): MorphMany { return $this->morphMany(Meta::getProxiedClass(), 'metable'); } + + /** + * Get the meta value of the given key. + */ + public function metaValue(string $key): mixed + { + return $this->metaData->firstWhere('key', $key)?->value; + } }