This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
johnny chen
build 2.1.4
in my Model class
public $jsonable = ['types'];
public function getTypesAttribute($value){
return $value
}
if convert this record to an array (.toArray() or json_encode),the attribute of 'types' is a string.
Last updated
daftspunky
Hey Johnny,
When you specify getTypesAttribute
you override the jsonable logic, which occurs in the getAttributeValue
method. You will need to decode the string, manipulate the value and then re-encode as a string for the return value. This seems like a lot of effort, so it might be better not to use jsonable
for this purpose.
I hope this helps.
1-2 of 2