예제 #1
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCaixaops()
 {
     return $this->hasMany(Caixaop::className(), ['caixa_idcaixa' => 'idcaixa']);
 }
예제 #2
0
 /**
  * Creates a new Caixa model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionOperacao()
 {
     $usuario = User::findOne(Yii::$app->user->id);
     $caixa = $usuario->caixaAberto();
     if (!$caixa) {
         return $this->redirect(['abre']);
     }
     $model = new Caixaop();
     $model->caixa_idcaixa = $caixa->idcaixa;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->idcaixa]);
     } else {
         return $this->render('operacao', ['model' => $model]);
     }
 }