public function handle($request, Closure $next, $guard = null) { if (ConfigQuery::create()->find()->count() === 0) { if ($request->ajax()) { return response('Unauthorized.', 401); } else { return redirect('/start'); } } return $next($request); }
public function getShownUsername() { $shown_user_name = ""; $required_fields = ConfigQuery::getRegisterRequiredFields(); if (!empty($required_fields)) { if (in_array("user_name", $required_fields)) { $shown_user_name = "user_name"; } elseif (in_array("user_login", $required_fields)) { $shown_user_name = "user_name"; } elseif (in_array("user_email", $required_fields)) { $shown_user_name = "user_email"; } } if (empty($shown_user_name)) { $shown_user_name = ConfigQuery::getLoginField(); } return $this->{$shown_user_name}; }
public function registerRequiredFields() { $register_required_fields = ConfigQuery::getRegisterRequiredFields(); if ($register_required_fields) { return $register_required_fields; } return array(); }
/** * Checks whether the current state must be recorded as a version * * @return boolean */ public function isVersioningNecessary($con = null) { if ($this->alreadyInSave) { return false; } if ($this->enforceVersion) { return true; } if (ChildConfigQuery::isVersioningEnabled() && ($this->isNew() || $this->isModified()) || $this->isDeleted()) { return true; } return false; }
/** * Get the associated ChildConfig object * * @param ConnectionInterface $con Optional Connection object. * @return ChildConfig The associated ChildConfig object. * @throws PropelException */ public function getConfig(ConnectionInterface $con = null) { if ($this->aConfig === null && $this->config_id !== null) { $this->aConfig = ChildConfigQuery::create()->findPk($this->config_id, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aConfig->addConfigI18ns($this); */ } return $this->aConfig; }
/** * Returns the number of related Config objects. * * @param Criteria $criteria * @param boolean $distinct * @param ConnectionInterface $con * @return int Count of related Config objects. * @throws PropelException */ public function countConfigs(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collConfigsPartial && !$this->isNew(); if (null === $this->collConfigs || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collConfigs) { return 0; } if ($partial && !$criteria) { return count($this->getConfigs()); } $query = ChildConfigQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query->filterByConfigCategory($this)->count($con); } return count($this->collConfigs); }
/** * Returns a new ChildConfigQuery object. * * @param string $modelAlias The alias of a model in the query * @param Criteria $criteria Optional Criteria to build the query from * * @return ChildConfigQuery */ public static function create($modelAlias = null, Criteria $criteria = null) { if ($criteria instanceof ChildConfigQuery) { return $criteria; } $query = new ChildConfigQuery(); if (null !== $modelAlias) { $query->setModelAlias($modelAlias); } if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
/** * Performs an INSERT on the database, given a Config or Criteria object. * * @param mixed $criteria Criteria or Config object containing data that is used to create the INSERT statement. * @param ConnectionInterface $con the ConnectionInterface connection to use * @return mixed The new primary key. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doInsert($criteria, ConnectionInterface $con = null) { if (null === $con) { $con = Propel::getServiceContainer()->getWriteConnection(ConfigTableMap::DATABASE_NAME); } if ($criteria instanceof Criteria) { $criteria = clone $criteria; // rename for clarity } else { $criteria = $criteria->buildCriteria(); // build Criteria from Config object } if ($criteria->containsKey(ConfigTableMap::COL_CONFIG_ID) && $criteria->keyContainsValue(ConfigTableMap::COL_CONFIG_ID)) { throw new PropelException('Cannot insert a value for auto-increment primary key (' . ConfigTableMap::COL_CONFIG_ID . ')'); } // Set the correct dbName $query = ConfigQuery::create()->mergeWith($criteria); // use transaction because $criteria could contain info // for more than one table (I guess, conceivably) return $con->transaction(function () use($con, $query) { return $query->doInsert($con); }); }