[ 'class' => Index::class, 'columns' => [ 'name' => [ 'type' => Index::ACTION_COL, 'columnConfig' => [ 'buttonsTemplate' => '{edit}{delete}', ], ], 'secondname' => [ 'type' => Index::STRING_COL, ], 'organization' => [ 'type' => Index::STRING_COL, ], ], 'model' => Customer::class, 'hasLanguage' => false, 'enableMassDelete' => true, 'modelPrimaryKey' => 'id', 'create' => false, ], ]; } public function actionUpdate($id) { $model = $this->findModel($id); return $this->render( 'update', [ 'model' => $model, ] ); } /** * @param $id * * @return \common\models\Customer|mixed|null * @throws \yii\web\NotFoundHttpException */ public function findModel($id) { $model = Customer::findOne($id); if ($model) { return $model; } else { throw new NotFoundHttpException(); } } /** * Create new model * * @return mixed */ public function newModel() { return new Customer(); } /** * @param $id * * @return bool|mixed * @throws \Throwable * @throws \yii\db\StaleObjectException * @throws \yii\web\NotFoundHttpException */ public function deleteModel($id) { $model = $this->findModel($id); if ($model->delete()) { return true; } else { return false; } } }