Jelajahi Sumber

логин-добавление рег счета если не существует

ks 3 bulan lalu
induk
melakukan
6eb784089a
1 mengubah file dengan 18 tambahan dan 0 penghapusan
  1. 18 0
      controllers/SiteController.php

+ 18 - 0
controllers/SiteController.php

@@ -17,6 +17,7 @@ use yii\data\ActiveDataProvider;
 use yii\web\NotFoundHttpException;
 use yii\web\Response;
 use yii\widgets\ActiveForm;
+use app\models\Bills;
 
 class SiteController extends Controller
 {
@@ -82,6 +83,23 @@ class SiteController extends Controller
         }
     
         if ($model->load(Yii::$app->request->post()) && $model->login()) {
+            // если нет регистрационного счета - делаем
+            if(!$bills = Bills::find()
+            ->where([
+                'user_id' => Yii::$app->user->id,
+                'type' => 'registration'
+            ])->one()){
+                (new Bills(
+                    [
+                        'user_id' => Yii::$app->user->id,
+                        'type' => 'registration',
+                        'payed' => 0,
+                        'bid_id' => NULL,
+                        'auction_id' => NULL,
+                    ]
+                ))->save(false);
+            }
+           
             return $this->redirect(['/cabinet']);
         }