/** * @param bool|true $safe * @return $this */ public function returnObjects($safe = true) { $cls = $this->metadata->getModelClass(); $dbColsAsKeys = array_flip($this->metadata->getDbColNames()); $this->rowDataMapper = function ($row) use($cls, $dbColsAsKeys, $safe) { if ($safe) { return new $cls(array_intersect_key($row, $dbColsAsKeys), false); } else { return new $cls($row, false); } }; return $this; }
/** * @param array $arguments * @return Model */ public function getOrCreate(array $arguments) { try { return $this->get($arguments); } catch (\RuntimeException $e) { $class = $this->metadata->getModelClass(); return new $class($arguments); } }