Exemplo n.º 1
0
 public static function getActiveToken($token)
 {
     $activeQuery = new ActiveQuery(self::className());
     $activeQuery->where('access_token = :token', [':token' => $token]);
     $activeQuery->andWhere('expires > now()');
     $token = $activeQuery->one();
     return $token;
 }
Exemplo n.º 2
0
 /**
  * @inheritdoc
  * @return Parametro|array|null
  */
 public function activeByNameDecoded($name, $db = null)
 {
     $ret = parent::where(['nombre' => $name])->andWhere('fecha_fin is null')->one();
     if (!$ret) {
         return null;
     }
     return Json::decode($ret->valor);
 }
 /**
  * Set catering parameters.
  *
  * @param null $db
  * @param array $values
  */
 public function catering($db = null, $values)
 {
     /** @var Settings $row */
     $row = parent::where(['key' => 'catering'])->one($db);
     $newValue = json_encode($values);
     if (false === $newValue) {
         Yii::error(__METHOD__ . '=> `json_encode` failed!');
         return;
     }
     $this->createOrUpdateSettings($row, 'catering', $newValue);
 }
Exemplo n.º 4
0
 /**
  * Finds a profile.
  *
  * @param mixed $condition
  *
  * @return \yii\db\ActiveQuery
  */
 public function findProfile($condition)
 {
     return $this->profileQuery->where($condition);
 }
 /**
  * Get catering settings as array.
  *
  * @param null $db
  * @return array|null
  */
 public function catering($db = null)
 {
     /** @var Settings $row   */
     $row = parent::where(['key' => 'catering'])->one($db);
     return is_null($row) ? ['host' => '', 'bank_id' => '', 'password' => '', 'use_account_type' => false] : json_decode($row->value, true);
 }
Exemplo n.º 6
0
 public function countProductsForOrder($id)
 {
     return parent::where(['order_id' => $id])->count();
 }
 /**
  * Finds a category by the given condition.
  *
  * @param mixed $condition Condition to be used on search.
  *
  * @return \yii\db\ActiveQuery
  */
 public function findComment($condition)
 {
     return $this->commentQuery->where($condition);
 }
Exemplo n.º 8
0
 public static function getTaskModel($id)
 {
     if (!isset($id)) {
         return false;
     }
     $query = new ActiveQuery(new Task());
     return $query->where(['id' => $id])->one();
 }
Exemplo n.º 9
0
 public function getSubtasks()
 {
     $query = new ActiveQuery(new Task());
     return $query->where(['projectID' => $this->projectID, 'parenttask' => $this->id])->all();
 }
Exemplo n.º 10
0
 public function findNoteById($id)
 {
     return $this->noteQuery->where(['id' => $id])->one();
 }
Exemplo n.º 11
0
 /**
  * Finds a user type.
  *
  * @param mixed $condition
  *
  * @return \yii\db\ActiveQuery
  */
 public function findUserType($condition)
 {
     return $this->userTypeQuery->where($condition);
 }
Exemplo n.º 12
0
 /**
  * Finds a page by the given condition.
  *
  * @param mixed $condition Condition to be used on search.
  *
  * @return \yii\db\ActiveQuery
  */
 public function findPage($condition)
 {
     return $this->pageQuery->where($condition);
 }
Exemplo n.º 13
0
 /**
  * Finds a page by the given condition.
  *
  * @param mixed $condition Condition to be used on search.
  *
  * @return \yii\db\ActiveQuery
  */
 public function findBlock($condition)
 {
     return $this->blockQuery->where($condition);
 }