From 4dc8c8d4e9fece4385e7cce47c04e10f7c0e127c Mon Sep 17 00:00:00 2001 From: BMTmohammedtaha Date: Fri, 1 Dec 2023 16:26:23 +0100 Subject: [PATCH] add jsonSerialize method --- src/Model.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Model.php b/src/Model.php index 1fc8dd0..9f5b7a5 100644 --- a/src/Model.php +++ b/src/Model.php @@ -25,7 +25,7 @@ * * @package Effectra\Database */ -class Model +class Model implements \JsonSerializable { use ModelEventTrait; /** @@ -1112,6 +1112,16 @@ public static function getQueryUsedAsString(): string return (string) static::getQueryUsed(); } + /** + * Specify data which should be serialized to JSON. + * + * @return array Data which can be serialized by json_encode(). + */ + public function jsonSerialize(): array + { + return $this->getEntries(); + } + /** * dump model class using `Symfony\Component\VarDumper\VarDumper` package *