kresek kresek - 2 years ago 110
PHP Question

Get real value after create custom model attribute in laravel

i was editing code from other programmer, and i found this code in model

public function getContentAttribute($value) {
return (json_decode($value, true));

And how to get the real value when i call
without removing the custom model attribute function?

Answer Source

You will need to define another accessor:

public function getContentOriginalAttribute($value) {
    return $this->attributes['content'];

Then accessing it this way:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download