/** * Creates a new Sales model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate($store) { $model = new Sales(); $model->date = date('Y-m-d H:i:s'); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['stores/view', 'id' => $model->fkstore_id]); } else { return $this->render('create', ['model' => $model, 'store' => Stores::findOne($store), 'fruit' => Fruit::find()->asArray()->all()]); } }
/** * @return \yii\db\ActiveQuery */ public function getFruit() { return $this->hasOne(Fruit::className(), ['fruit_id' => 'fkfruit_id']); }