Skip to content

Commit 4b75fd6

Browse files
committed
Add jsonSerialize method to implement the JsonSerializable interface
1 parent 5c24120 commit 4b75fd6

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/Traits/SerializableTrait.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,12 @@ private function evaluateAttribute(string $property, $attribute, int $depth)
8888
: get_object_vars($attribute)
8989
);
9090
}
91+
92+
/**
93+
* Return a JSON serializable representation of the current state
94+
*/
95+
public function jsonSerialize()
96+
{
97+
return $this->toArray();
98+
}
9199
}

0 commit comments

Comments
 (0)