/** * Finds the Attribute model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Attribute the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Attribute::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public static function getAttributeId($attrib_name = '') { $model = Attribute::findOne(['name' => $attrib_name]); if ($model) { return $model->id; } else { return 0; } }
public function actionAttrdel($id, $type_id) { $model = Attribute::findOne($id); if ($model->delete()) { Yii::$app->getSession()->setFlash('info', '操作删除成功!'); return $this->redirect(['attrlist', 'type_id' => $type_id]); } }