Example #1
0
 public function getPriceCategory()
 {
     return $this->hasOne(FPriceCategory::className(), ['id_category' => 'id']);
 }
Example #2
0
 public function actionItem()
 {
     $get = Yii::$app->request->get();
     $id = $get["id"];
     $cat = FCategory::findOne($id);
     $option = FPriceCategory::findOne(["id_category" => $id]);
     if (!$option) {
         $option = new FPriceCategory();
         $option->id_category = $id;
         $option->save();
     }
     if (Yii::$app->request->isPost) {
         $post = Yii::$app->request->post();
         $option->load($post);
         if ($option->validate()) {
             $option->save();
         }
     }
     return $this->render('item', ['r_cat' => $cat, 'option' => $option]);
 }