/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Cat::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, 'status' => $this->status]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'created_at', $this->created_at])->andFilterWhere(['like', 'updated_at', $this->updated_at]); return $dataProvider; }
use yii\helpers\Html; use yii\widgets\ActiveForm; use common\models\UcenterMember; use yii\helpers\ArrayHelper; use yii\helpers\Url; use kartik\file\FileInput; use common\models\base\ucenter\Cat; use common\models\base\ucenter\Catmiddle; /* @var $this yii\web\View */ /* @var $model common\models\UcenterMember */ /* @var $form yii\widgets\ActiveForm */ $allcat = Cat::find()->all(); $cattype = Catmiddle::find()->where(['uid' => $model->id])->asArray()->all(); $cat = []; foreach ($cattype as $k => $v) { $newname = Cat::find()->where(['id' => $v['cid']])->asArray()->one(); array_push($cat, $newname['id']); } ?> <div class="ucenter-member-form"> <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?> <?php echo $form->field($model, 'username')->textInput(['maxlength' => true]); ?> <?php
/** * Finds the Cat model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Cat the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Cat::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public static function getCusStatus() { $cat = Cat::find()->select('id,name')->asArray()->all(); $name = array_column($cat, 'name', 'id'); return $name; }