/** * Finds the Academia model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Academia the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Academia::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Creates a new Pago model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate($academia = 0) { $model = new Pago(); $model->academia = $academia; $searchModel = new PagoSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); $model_detalle_academia = Academia::findOne(['id' => $academia]); $meses_a_pagar = Pago::calcularMesesDeuda($academia); $periodo_a_pagar = Pago::calcularPeriodoAPagar($academia); $valor_a_pagar = Pago::calcularValorAPagar($academia); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->refresh(); } else { return $this->render('create', ['model' => $model, 'model_detalle_academia' => $model_detalle_academia, 'meses_a_pagar' => $meses_a_pagar, 'periodo_a_pagar' => $periodo_a_pagar, 'valor_a_pagar' => $valor_a_pagar, 'searchModel' => $searchModel, 'dataProvider' => $dataProvider]); } }