Пример #1
0
 /**
  * Creates a new Expenses model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Expenses();
     if ($model->load(Yii::$app->request->post())) {
         $model->loadDefaultValues();
         $model->save();
         if ($model->save()) {
             $exp = new EntpExpenses();
             $exp->expenses_id = $this->id;
             $exp->entrepreneur_id = Yii::$app->user->id;
             $exp->link('expenses', $model);
         }
         Yii::$app->session->setFlash('success', 'ok');
         $searchModel = new EntpExpensesSearch();
         $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
         return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
         //return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Пример #2
0
 /**
  * Lists all EntpExpenses models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new EntpExpensesSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }