diff --git a/README.md b/README.md index 8b44f54..cb8aac8 100644 --- a/README.md +++ b/README.md @@ -165,6 +165,8 @@ This functionality is most suited for meta entries that note exceptions to rules ]; ``` +> **Note:** Make sure to use lowercase keys. + #### Gotcha When you extend a model and still want to use the same meta table you must override `getMetaKeyName` function. @@ -363,6 +365,10 @@ unset($post->content);// will not unset meta isset($post->content);// will not check if meta exists ``` +#### Using Original `getAttribute` and `setAttribute` Methods + +Laravel meta overrides these Laravel methods for fluent access. If you’ve already disabled fluent access using the method above, these methods' behavior won't change. Otherwise, you can use `getAttributeRaw` and `setAttributeRaw` to access the original methods. + #### Retrieving All Metas To fetch all metas associated with a piece of content, use the `getMeta` without any params diff --git a/src/Kodeine/Metable/Metable.php b/src/Kodeine/Metable/Metable.php index c3496bb..820766c 100644 --- a/src/Kodeine/Metable/Metable.php +++ b/src/Kodeine/Metable/Metable.php @@ -419,6 +419,27 @@ public function toArray(): array { ] ); } + /** + * Calls to laravel's getAttribute method. + * + * @param $key + * @return mixed + */ + public function getAttributeRaw($key) { + return parent::getAttribute( $key ); + } + + /** + * Calls to laravel's setAttribute method. + * + * @param $key + * @param $value + * @return mixed + */ + public function setAttributeRaw($key, $value) { + return parent::setAttribute( $key, $value ); + } + /** * Model Override functions * -------------------------.