/** * 通过客服常用问题分类的slug获取该分类下的所有数据 * @param $categorySlug 客服常用问题分类slug * @param $limit 限制返回的数据个数 * @return array|\yii\db\ActiveRecord[] */ public static function getKefuFaqbyCategorySlug($categorySlug, $limit) { $qiTaWenTis = KefuFaq::find()->where(['status' => KefuFaq::STATUS_IN_USE, 'category_id' => KefuFaqCat::findOne(['slug' => $categorySlug])['id']])->orderBy("created_at DESC")->limit($limit)->all(); return $qiTaWenTis; }
/** * Finds the KefuFaqCat model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return KefuFaqCat the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = KefuFaqCat::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }