/** * Hydrates the model with the given data. * * @param mixed $data */ public function hydrate($data) { $colMap = array_flip($this->columnMap()); foreach (Util::iterate($data) as $key => $value) { if (isset($colMap[$key])) { $key = $colMap[$key]; } $this->{$key} = $value; } $this->onHydrate(); }
/** * Hydrates the model with the given data. * * @param mixed $data */ public function hydrate($data) { foreach (Util::iterate($data) as $key => $value) { if ('data' === $key) { foreach ((array) $value as $k => $v) { $this->{$k} = $v; } } else { $this->{$key} = $value; } } $this->onHydrate(); }