Пример #1
0
 /**
  * 
  * @param string|integer $id
  * @param boolean $throwExceptionIfNull
  * @return Article
  * @throws \yii\web\NotFoundHttpException
  */
 public static function getArticle($id, $throwExceptionIfNull = true)
 {
     if (is_numeric($id)) {
         $article = Article::find()->id($id)->one();
         if ($article) {
             return $article;
         }
     }
     if (is_string($id)) {
         $article = Article::find()->name($id)->one();
         if ($article) {
             return $article;
         }
     }
     if ($throwExceptionIfNull) {
         throw new \yii\web\NotFoundHttpException(static::t('Article Not Found.'));
     }
     return null;
 }
Пример #2
0
 /**
  * 
  * @return \rhopress\models\ArticleQuery
  */
 public function getArticle()
 {
     $article = Article::buildNoInitModel();
     return $this->hasOne(Article::className(), [$article->guidAttribute => 'article_guid']);
 }
Пример #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getArticles()
 {
     $article = Article::buildNoInitModel();
     return $this->hasMany(Article::className(), [$article->createdByAttribute => $this->guidAttribute])->inverseOf('user');
 }