/** * @param bool $user * @return bool */ public function isFavorite($user = false) { $user = $user ? $user : Yii::$app->user; return Favorite::find()->where(['user_id' => $user->id, 'question_id' => $this->id])->exists(); }
/** * @inheritdoc */ public function run() { $models = FavoriteModel::find()->limit($this->limit)->where(['user_id' => $this->userID])->with('question')->all(); return $this->render('favorite', ['models' => $models]); }