Skip to content

Commit 7177024

Browse files
authored
Merge pull request #119 from siamak2/2.x
Added getAttributeRaw and setAttributeRaw
2 parents 2843eb4 + 8ae418b commit 7177024

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ This functionality is most suited for meta entries that note exceptions to rules
165165
];
166166
```
167167

168+
> **Note:** Make sure to use lowercase keys.
169+
168170
#### Gotcha
169171

170172
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
363365
isset($post->content);// will not check if meta exists
364366
```
365367

368+
#### Using Original `getAttribute` and `setAttribute` Methods
369+
370+
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.
371+
366372
#### Retrieving All Metas
367373

368374
To fetch all metas associated with a piece of content, use the `getMeta` without any params

src/Kodeine/Metable/Metable.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,27 @@ public function toArray(): array {
419419
] );
420420
}
421421

422+
/**
423+
* Calls to laravel's getAttribute method.
424+
*
425+
* @param $key
426+
* @return mixed
427+
*/
428+
public function getAttributeRaw($key) {
429+
return parent::getAttribute( $key );
430+
}
431+
432+
/**
433+
* Calls to laravel's setAttribute method.
434+
*
435+
* @param $key
436+
* @param $value
437+
* @return mixed
438+
*/
439+
public function setAttributeRaw($key, $value) {
440+
return parent::setAttribute( $key, $value );
441+
}
442+
422443
/**
423444
* Model Override functions
424445
* -------------------------.

0 commit comments

Comments
 (0)