From 5834cb60f5ca1c787c2232995ca2e270a5bb6d0f Mon Sep 17 00:00:00 2001 From: Siamak Salimi Date: Tue, 8 Apr 2025 23:56:31 +0330 Subject: [PATCH 1/2] Added getAttributeRaw and setAttributeRaw --- README.md | 4 ++++ src/Kodeine/Metable/Metable.php | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/README.md b/README.md index 8b44f54..6c03df9 100644 --- a/README.md +++ b/README.md @@ -363,6 +363,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 * -------------------------. From 8ae418bae464e79c8eeee47ea4ee9e5e0de98f9f Mon Sep 17 00:00:00 2001 From: Siamak Salimi Date: Wed, 9 Apr 2025 00:13:09 +0330 Subject: [PATCH 2/2] Added note about defaultMetaValues keys being lowercase. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 6c03df9..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.