/** * 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()]); } }
/** * Finds the Stores model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Stores the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Stores::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }