Exemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = KefuFaq::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'category_id' => $this->category_id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'content', $this->content]);
     return $dataProvider;
 }
Exemplo n.º 2
0
use yii\helpers\Html;
use yii\helpers\ArrayHelper;
use yii\grid\GridView;
use common\models\KefuFaq;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\search\KefuFaqSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('common', 'Kefu Faq');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="kefu-faq-index">

	<?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

	<p>
		<?php 
echo Html::a(Yii::t('backend', 'Create {modelClass}', ['modelClass' => Yii::t('common', 'Kefu Faq')]), ['create'], ['class' => 'btn btn-success']);
?>
	</p>

	<?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'title', ['attribute' => 'category_id', 'value' => function ($model) {
    return $model->category ? $model->category->title : null;
}, 'filter' => ArrayHelper::map(\common\models\KefuFaqCat::find()->all(), 'id', 'title')], 'description', ['class' => \common\grid\EnumColumn::className(), 'attribute' => 'status', 'enum' => KefuFaq::getStatus()], ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>
Exemplo n.º 3
0
<?php

use yii\helpers\Html;
use yii\helpers\ArrayHelper;
use yii\widgets\DetailView;
use common\models\KefuFaq;
/* @var $this yii\web\View */
/* @var $model common\models\KefuFaq */
$this->title = $model->title;
$this->params['breadcrumbs'][] = ['label' => Yii::t('common', 'Kefu Faq'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="kefu-faq-view">

	<p>
		<?php 
echo Html::a(Yii::t('backend', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']);
?>
		<?php 
echo Html::a(Yii::t('backend', 'Delete'), ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => Yii::t('backend', 'Are you sure you want to delete this item?'), 'method' => 'post']]);
?>
	</p>

	<?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['title', ['attribute' => 'category_id', 'value' => $model->category ? $model->category->title : null], 'description', 'content:html', 'created_at:datetime', 'updated_at:datetime', ['attribute' => 'status', 'value' => ArrayHelper::getValue(KefuFaq::getStatus(), $model->status)]]]);
?>

</div>
Exemplo n.º 4
0
 /**
  * 通过客服常用问题分类的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;
 }
Exemplo n.º 5
0
 /**
  * Finds the KefuFaq model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return KefuFaq the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = KefuFaq::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemplo n.º 6
0
echo $form->field($model, 'category_id')->dropDownList(\yii\helpers\ArrayHelper::map($categories, 'id', 'title'), ['prompt' => Yii::t('common', '')]);
?>

	<?php 
echo $form->field($model, 'title')->textInput(['maxlength' => true]);
?>

	<?php 
echo $form->field($model, 'description')->textInput(['maxlength' => true]);
?>

	<?php 
echo $form->field($model, 'content')->textarea(['rows' => 6]);
?>

	<?php 
echo $form->field($model, 'status')->radioList(KefuFaq::getStatus());
?>

	<div class="form-group">
		<?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('backend', 'Create') : Yii::t('backend', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
	</div>

	<?php 
ActiveForm::end();
?>

</div>
Exemplo n.º 7
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getKefuFaqs()
 {
     return $this->hasMany(KefuFaq::className(), ['category_id' => 'id']);
 }