Skip to content

Commit

Permalink
Если данные в результате запроса одного элемента возвращаются в парам…
Browse files Browse the repository at this point in the history
…етре отличном от имени класса, нужно указать корректное значение в alias_one
  • Loading branch information
kazartsev committed Mar 27, 2018
1 parent 5a3903d commit 8da7523
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Sberned/RestORM/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ abstract class Model implements Arrayable, ArrayAccess, Jsonable, JsonSerializab
*/
private $className = '';

public $alias_one = null;

/**
* @var array
*/
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 8da7523

Please sign in to comment.