From 8da7523fc042e00df8c9c93b1ce10d83a3b00717 Mon Sep 17 00:00:00 2001 From: Dmitry Kazartsev Date: Tue, 27 Mar 2018 13:08:16 +0300 Subject: [PATCH] =?UTF-8?q?=D0=95=D1=81=D0=BB=D0=B8=20=D0=B4=D0=B0=D0=BD?= =?UTF-8?q?=D0=BD=D1=8B=D0=B5=20=D0=B2=20=D1=80=D0=B5=D0=B7=D1=83=D0=BB?= =?UTF-8?q?=D1=8C=D1=82=D0=B0=D1=82=D0=B5=20=D0=B7=D0=B0=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D1=81=D0=B0=20=D0=BE=D0=B4=D0=BD=D0=BE=D0=B3=D0=BE=20=D1=8D?= =?UTF-8?q?=D0=BB=D0=B5=D0=BC=D0=B5=D0=BD=D1=82=D0=B0=20=D0=B2=D0=BE=D0=B7?= =?UTF-8?q?=D0=B2=D1=80=D0=B0=D1=89=D0=B0=D1=8E=D1=82=D1=81=D1=8F=20=D0=B2?= =?UTF-8?q?=20=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82=D1=80=D0=B5=20?= =?UTF-8?q?=D0=BE=D1=82=D0=BB=D0=B8=D1=87=D0=BD=D0=BE=D0=BC=20=D0=BE=D1=82?= =?UTF-8?q?=20=D0=B8=D0=BC=D0=B5=D0=BD=D0=B8=20=D0=BA=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D1=81=D0=B0,=20=D0=BD=D1=83=D0=B6=D0=BD=D0=BE=20=D1=83=D0=BA?= =?UTF-8?q?=D0=B0=D0=B7=D0=B0=D1=82=D1=8C=20=D0=BA=D0=BE=D1=80=D1=80=D0=B5?= =?UTF-8?q?=D0=BA=D1=82=D0=BD=D0=BE=D0=B5=20=D0=B7=D0=BD=D0=B0=D1=87=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=B2=20alias=5Fone?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Sberned/RestORM/Model.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Sberned/RestORM/Model.php b/src/Sberned/RestORM/Model.php index 19edc1e..509cbd4 100644 --- a/src/Sberned/RestORM/Model.php +++ b/src/Sberned/RestORM/Model.php @@ -87,6 +87,8 @@ abstract class Model implements Arrayable, ArrayAccess, Jsonable, JsonSerializab */ private $className = ''; + public $alias_one = null; + /** * @var array */ @@ -276,7 +278,8 @@ public function findOne(int $id) $className = $this->className; - $data = $res->$className; + $data = $this->alias_one ? $res->{$this->alias_one} : $res->$className; + if(!empty($data)) { foreach ($data as $key => $val) { $this->setAttribute($key, $val);