当前位置: 首页>>代码示例>>PHP>>正文


PHP Customer::load方法代码示例

本文整理汇总了PHP中app\models\Customer::load方法的典型用法代码示例。如果您正苦于以下问题:PHP Customer::load方法的具体用法?PHP Customer::load怎么用?PHP Customer::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\Customer的用法示例。


在下文中一共展示了Customer::load方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionCreate

 /**
  * Creates a new Customer model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Customer();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
开发者ID:vbboy2012,项目名称:1861886,代码行数:14,代码来源:CustomerController.php

示例2: actionLogin

 public function actionLogin()
 {
     $model = new Customer();
     if ($model->load(Yii::$app->request->post())) {
         $request = Yii::$app->request->post('Customer');
         $username = $request['username'];
         $password = $request['password'];
         if ($model->checkLogin($username, $password)) {
             $customerName = $model->getName($username);
             Yii::$app->session->set('customer', $customerName);
             $this->redirect(['site/index']);
         } else {
             $this->redirect(['login', 'error' => 'Tên đăng nhập hoặc mật khẩu không đúng!']);
         }
     }
     return $this->render('login', ['model' => $model]);
 }
开发者ID:royutoan,项目名称:pianodanang,代码行数:17,代码来源:CustomerController.php

示例3: actionCreate

 /**
  * Creates a new Customer model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Customer();
     if ($model->load(Yii::$app->request->post())) {
         $tax_number = $model->tax_number;
         $check = $model->find()->where(['tax_number' => $tax_number])->one();
         if ($check['tax_number'] != '') {
             $config = new \app\models\Config_system();
             $cusId = $config->autoId("customer", "cus_id", 7);
             return $this->render('create', ['error' => "ลูกค้าบริษัทนี้นี้มีอยู่ในระบบแล้ว ...!", 'model' => $model, 'cus_id' => $cusId]);
         } else {
             $model->create_date = date("Y-m-d H:i:s");
             $model->save();
             return $this->redirect(['view', 'id' => $model->id]);
         }
     } else {
         $config = new \app\models\Config_system();
         $cusId = $config->autoId("customer", "cus_id", 7);
         return $this->render('create', ['error' => '', 'model' => $model, 'cus_id' => $cusId]);
     }
 }
开发者ID:kimniyom,项目名称:transport,代码行数:26,代码来源:CustomerController.php

示例4: actionCreateCustomerAndReservation

 public function actionCreateCustomerAndReservation()
 {
     $customer = new Customer();
     $reservation = new Reservation();
     $reservation->customer_id = 0;
     if ($customer->load(Yii::$app->request->post()) && $reservation->load(Yii::$app->request->post()) && $customer->validate() && $reservation->validate()) {
         $dbTrans = Yii::$app->db->beginTransaction();
         $customerSaved = $customer->save();
         if ($customerSaved) {
             $reservation->customer_id = $customer->id;
             $reservationSaved = $reservation->save();
             if ($reservationSaved) {
                 $dbTrans->commit();
             } else {
                 $dbTrans->rollback();
             }
         } else {
             $dbTrans->rollback();
         }
     }
     return $this->render('createCustomerAndReservation', ['customer' => $customer, 'reservation' => $reservation]);
 }
开发者ID:AntoninSlejska,项目名称:yii-test,代码行数:22,代码来源:ReservationsController.php

示例5: actionCreateCustomerAndReservation

 public function actionCreateCustomerAndReservation()
 {
     $customer = new \app\models\Customer();
     $reservation = new \app\models\Reservation();
     // It is useful to set fake customer_id to reservation model to avoid validationerror (because customer_id is mandatory)
     $reservation->customer_id = 0;
     if ($customer->load(Yii::$app->request->post()) && $reservation->load(Yii::$app->request->post()) && $customer->validate() && $reservation->validate()) {
         $dbTrans = Yii::$app->db->beginTransaction();
         $customerSaved = $customer->save();
         if ($customerSaved) {
             $reservation->customer_id = $customer->id;
             $reservationSaved = $reservation->save();
             if ($reservationSaved) {
                 $dbTrans->commit();
             } else {
                 $dbTrans->rollback();
             }
         } else {
             $dbTrans->rollback();
         }
     }
     return $this->render('createCustomerAndReservation', ['customer' => $customer, 'reservation' => $reservation]);
 }
开发者ID:QiLiuXianSheng,项目名称:yii2,代码行数:23,代码来源:ReservationsController.php


注:本文中的app\models\Customer::load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。