/** * 1.- Get the database connection for the model. * 2.- Execute a Closure within a transaction. * 3.- Find a model by its primary key or return new static. * 4.- Save the model to the database. * * Guarda todas las configuraciones proporcionadas por el usuario. * * * @access public * @param array $configuracion * @return array */ public static function guardaConfiguracion(array $configuracion = array()) { $self = new self(); $conn = $self->getConnection(); $conn->transaction(function () use($self, $configuracion) { foreach ($configuracion as $clave => $valor) { $model = $self->findOrNew($clave); $model->clave = $clave; $model->valor = $valor; $model->save(); } }); return $configuracion; }