示例#1
0
 /**
  * Find bu name
  * @author Kravchuk Dmitry
  *
  * @param string $name
  *
  * @return $this
  */
 public function byName($name)
 {
     $tableColumn = SeoCategoryModel::tableName() . '.name';
     $aliasColumn = ':' . SeoCategoryModel::tableName() . 'Name';
     $this->andWhere($tableColumn . ' = ' . $aliasColumn, [$aliasColumn => $name]);
     return $this;
 }
示例#2
0
 /**
  * Creates data provider instance with search query applied
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = SeoCategoryModel::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'position' => $this->position, 'createdAt' => $this->createdAt, 'updatedAt' => $this->updatedAt]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'comment', $this->comment]);
     return $dataProvider;
 }
示例#3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCategory()
 {
     return $this->hasOne(SeoCategoryModel::className(), ['id' => 'categoryId']);
 }
示例#4
0
?>

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

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

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

    <?php 
echo $form->field($model, 'categoryId')->dropDownList(ArrayHelper::map(SeoCategoryModel::find()->active()->all(), 'id', 'name'));
?>

    <?php 
echo $form->field($model, 'status')->dropDownList(SeoStatus::$editList);
?>

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

    <?php 
ActiveForm::end();
?>
示例#5
0
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a(Yii::t('app', 'Create {modelClass}', ['modelClass' => 'Seo']), ['create'], ['class' => 'btn btn-success']);
?>
    </p>
    <?php 
\yii\widgets\Pjax::begin(['enablePushState' => false, 'timeout' => 10000]);
?>
    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => ['id', 'url', 'urlRule', ['class' => EditableColumn::className(), 'attribute' => 'name', 'url' => ['edit-seo-name']], ['class' => EditableColumn::className(), 'url' => ['edit-seo-status'], 'type' => 'select', 'editableOptions' => function ($model) {
    return ['source' => Json::encode(SeoStatus::$editList), 'value' => $model->status];
}, 'filterInputOptions' => ['prompt' => 'Select Status', 'class' => 'form-control'], 'attribute' => 'status', 'value' => function ($model) {
    return SeoStatus::getLabel($model->status);
}, 'filter' => SeoStatus::$list], ['class' => EditableColumn::className(), 'url' => ['edit-seo-category'], 'type' => 'select', 'editableOptions' => function ($model) {
    return ['source' => Json::encode(ArrayHelper::map(SeoCategoryModel::find()->active()->all(), 'id', 'name')), 'value' => $model->categoryId];
}, 'filterInputOptions' => ['prompt' => 'Select Category', 'class' => 'form-control'], 'attribute' => 'categoryId', 'value' => function ($model) {
    $categoryModel = SeoCategoryModel::findOne($model->categoryId);
    return !empty($categoryModel) ? $categoryModel->name : '';
}, 'filter' => ArrayHelper::map(SeoCategoryModel::find()->order()->all(), 'id', 'name')], ['header' => 'Action', 'class' => 'yii\\grid\\ActionColumn', 'template' => '{view}{update}{delete}', 'buttons' => ['view' => function ($url, $model) {
    return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', Url::to($model->url, true), ['title' => 'View', 'data-pjax' => 0, 'target' => '_blank']);
}]]]]);
?>
    <?php 
\yii\widgets\Pjax::end();
?>

</div>
 /**
  * Finds the SeoCategoryModel model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return SeoCategoryModel the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = SeoCategoryModel::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }