Ejemplo n.º 1
0
 protected function findModel($id)
 {
     if (($model = Settings::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 2
0
 /**
  * @param $params
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Settings::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'section' => $this->section]);
     $query->andFilterWhere(['like', 'key', $this->key])->andFilterWhere(['like', 'value', $this->value]);
     return $dataProvider;
 }
Ejemplo n.º 3
0
//use yii\widgets\Pjax;
/**
 * @var yii\web\View $this
 * @var pheme\settings\models\SettingSearch $searchModel
 * @var yii\data\ActiveDataProvider $dataProvider
 */
$this->title = Yii::t('backend', 'Settings');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="box box-primary">
    <div class="box-body">

    <p>
        <?php 
echo Html::a(Yii::t('backend', 'Create Settings'), ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
//Pjax::begin();
?>
    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['attribute' => 'section', 'filter' => ArrayHelper::map(Settings::find()->select('section')->distinct()->where(['<>', 'section', ''])->all(), 'section', 'section')], 'key', 'value:ntext', ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update} {delete}', 'contentOptions' => ['class' => 'actionColumn'], 'buttonOptions' => ['class' => 'btn btn-sm btn-default', 'style' => 'padding:1px 10px;']]]]);
?>
    <?php 
//Pjax::end();
?>

    </div>
</div>