コード例 #1
0
 public function actionIndex($realty_groups_id = null, $id = null)
 {
     $realty_good = new RealtyGoods();
     if ($realty_groups_id) {
         $realty_good->realty_groups_id = $realty_groups_id;
     }
     if ($id) {
         $realty_good = RealtyGoods::findOne($id);
     }
     if ($realty_good->load(Yii::$app->request->post()) && $realty_good->save()) {
         $this->redirect(['', 'action' => 'ch', 'id' => $realty_good->id]);
         Yii::$app->getSession()->setFlash('success', 'Изменения приняты');
     }
     return $this->render('index', ['realty_groups' => RealtyGroups::find()->orderBy(['name' => SORT_ASC])->all(), 'realty_good' => $realty_good, 'realty_goods' => RealtyGoods::find()->innerJoinWith('realtyGroup')->orderBy(['realty_groups.name' => SORT_ASC])->all()]);
 }
コード例 #2
0
ファイル: RealtyGoods.php プロジェクト: mark38/yii2-site-mng
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getRealtyGroup()
 {
     return $this->hasOne(RealtyGroups::className(), ['id' => 'realty_groups_id']);
 }