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; }
/** * @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); }
/** * 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); }
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); }
public static function getTaskModel($id) { if (!isset($id)) { return false; } $query = new ActiveQuery(new Task()); return $query->where(['id' => $id])->one(); }
public function getSubtasks() { $query = new ActiveQuery(new Task()); return $query->where(['projectID' => $this->projectID, 'parenttask' => $this->id])->all(); }
public function findNoteById($id) { return $this->noteQuery->where(['id' => $id])->one(); }
/** * Finds a user type. * * @param mixed $condition * * @return \yii\db\ActiveQuery */ public function findUserType($condition) { return $this->userTypeQuery->where($condition); }
/** * 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); }
/** * 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); }