Skip to content

Commit

Permalink
add getMeta method to post, fetching a meta value associated with the…
Browse files Browse the repository at this point in the history
… defined $key
  • Loading branch information
jgarib committed Jan 31, 2018
1 parent 56dec71 commit f2afa99
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Entity/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,23 @@ public function getMetas()
return $this->metas;
}

/**
* Get Meta
*
* @param $key
* @return mixed
*/
public function getMeta($key)
{
$meta = $this->metas->filter(function($meta) use ($key) {
if ($meta->getKey() == $key) {
return true;
}
});

return $meta->first()->getValue();
}

/**
* Add comment
*
Expand Down

0 comments on commit f2afa99

Please sign in to comment.