Browse Source

* make majestic models as orm-objects (only on single fetch record)

10_ballov-1431 Авторизация и вывод 3-й цены на мобильной версии зеленого моря
laravel5
dimti 5 years ago
parent
commit
984e9aa716
  1. 16
      Model/SqlModel.php

16
Model/SqlModel.php

@ -174,6 +174,22 @@ abstract class SqlModel extends Model
$cache_key->set($result); $cache_key->set($result);
} }
} }
$calledClassName = get_called_class();
if ($result) {
$orm = new $calledClassName;
foreach (get_object_vars($result) as $key => $value) {
if ($key == 'table') {
$key = 'table_field';
}
$orm->$key = $value;
}
return $orm;
}
return $result; return $result;
} }

Loading…
Cancel
Save