コード例 #1
0
ファイル: Row.php プロジェクト: Kompaneytsev/yii2-rest-api
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = RowModel::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'page_id' => $this->page_id, 'parent_id' => $this->parent_id, 'top' => $this->top, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by]);
     $query->andFilterWhere(['like', 'options', $this->options]);
     return $dataProvider;
 }
コード例 #2
0
 /**
  * @inheritdoc
  */
 public function getParent()
 {
     return $this->hasOne(Row::className(), ['id' => 'parent_id']);
 }
コード例 #3
0
ファイル: _form.php プロジェクト: Kompaneytsev/yii2-rest-api
use yii\helpers\ArrayHelper;
use yii\widgets\ActiveForm;
use app\models\blog\Row;
/* @var $this yii\web\View */
/* @var $model app\models\blog\ColumnEmber */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="column-ember-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'parent_id')->dropDownList(ArrayHelper::map(Row::getActive(), 'id', 'title'));
?>

    <?php 
echo $form->field($model, 'top')->textInput();
?>

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

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

    <?php 
コード例 #4
0
ファイル: _form.php プロジェクト: Kompaneytsev/yii2-rest-api
echo $form->field($model, 'title')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'fullWidth')->dropDownList([0 => 'Нет', 1 => 'Да']);
?>

    <?php 
echo $form->field($model, 'top')->textInput();
?>

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

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

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Добавить' : 'Сохранить', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

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

</div>
コード例 #5
0
 /**
  * Finds the Row model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Row the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Row::findOne($id)) !== null) {
         $model->fullWidth = $model->getFullWidth();
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #6
0
ファイル: Page.php プロジェクト: Kompaneytsev/yii2-rest-api
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getRows()
 {
     return $this->hasMany(Row::className(), ['page_id' => 'id']);
 }