Skip to content

Commit

Permalink
add meta value accessor
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo committed Feb 9, 2024
1 parent 1c25f34 commit a1f334b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Traits/HasMetaData.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit a1f334b

Please sign in to comment.