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


PHP Customer::save方法代码示例

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


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

示例1: actionCreateMultipleModels

 public function actionCreateMultipleModels()
 {
     $models = [];
     if (isset($_POST['Customer'])) {
         $validateOK = true;
         foreach ($_POST['Customer'] as $postObj) {
             $model = new Customer();
             $model->attributes = $postObj;
             $models[] = $model;
             $validateOK = $validateOK && $model->validate();
         }
         // All models are validated and will be saved
         if ($validateOK) {
             foreach ($models as $model) {
                 $model->save();
             }
             // Redirect to grid after save
             return $this->redirect(['grid']);
         }
     } else {
         for ($k = 0; $k < 3; $k++) {
             $models[] = new Customer();
         }
     }
     return $this->render('createMultipleModels', ['models' => $models]);
 }
开发者ID:QiLiuXianSheng,项目名称:yii2,代码行数:26,代码来源:CustomersController.php

示例2: save

 function save(array $params)
 {
     $response = new ResponseEntity();
     DB::transaction(function () use(&$response, $params) {
         $user = User::find(Auth::user()->id);
         $product = Product::find($params['product_id']);
         $cust = new Customer();
         $cust->first_name = $params['customer']['first_name'];
         $cust->last_name = $params['customer']['last_name'];
         $cust->phone_number = $params['customer']['phone_number'];
         $custCreated = $cust->save();
         if ($custCreated && $product && $user) {
             $sale = new Sale();
             $sale->user_id = $user->id;
             $sale->sale_status_id = Config::get('constants.sale_status.sale');
             $sale->product_id = $product->id;
             $sale->customer_id = $cust->id;
             $sale->date_sold = Carbon::createFromFormat('m/d/Y', $params['date_sold'])->toDateString();
             $sale->remarks = isset($params['remarks']) ? $params['remarks'] : '';
             $sale->order_number = $params['order_number'];
             $sale->ninety_days = isset($params['ninety_days']) ?: 0;
             $ok = $sale->save();
             if ($ok) {
                 $ok = $this->setIncentive($sale->user_id, $sale->date_sold);
                 $response->setMessages($ok ? ['Sale successfully created!'] : ['Failed to create sale!']);
                 $response->setSuccess($ok);
             } else {
                 $response->setMessages(['Failed to create sale!']);
             }
         } else {
             $response->setMessages(['Entities not found']);
         }
     });
     return $response;
 }
开发者ID:arjayads,项目名称:green-tracker,代码行数:35,代码来源:SaleService.php

示例3: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     try {
         $admin = \Auth::User();
         if (!$admin) {
             return $this->failResponse('admin not logged in');
         }
         $customerObj = new Customer();
         $data = $this->getRequestBody();
         $customerObj->first_name = $data['first_name'];
         $customerObj->last_name = $data['last_name'];
         $customerObj->business_name = $data['business_name'];
         $customerObj->mobile = $data['mobile'];
         $customerObj->email = $data['email'];
         $customerObj->address = $data['address'];
         $customerObj->save();
         if (!$customerObj->save()) {
             Log::error("error in saving");
             $errors = $customerObj->getErrors();
             return $this->failResponse('Validation failed. Cannot save data.' . $errors);
         } else {
             return $this->successResponse('updated sucessfully');
         }
     } catch (\Exception $e) {
         Log::error($customerObj->getErrors());
         return $this->failResponse($e->getMessage());
     }
 }
开发者ID:prathyushasahusoft,项目名称:Angular-Scripts,代码行数:33,代码来源:customerController.php

示例4: 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

示例5: postEdit

 public function postEdit($id)
 {
     $this->validateForm();
     $customer = new Customer($id);
     $customer->first_name = Request::get('first_name');
     $customer->last_name = Request::get('last_name');
     $customer->email = Request::get('email');
     $customer->phone = Request::get('phone');
     $customer->gender = Request::get('gender');
     $customer->save();
     return redirect('customer/' . $id);
 }
开发者ID:JSHOCKEY,项目名称:rockit_posCrud,代码行数:12,代码来源:CustomerController.php

示例6: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     //
     $validator = Validator::make($request->all(), ['name' => 'required|max:255']);
     if ($validator->fails()) {
         return redirect('/')->withInput()->withErrors($validator);
     }
     $customer = new Customer();
     $customer->name = $request->name;
     $customer->eng_name = $request->eng_name;
     $customer->save();
     Activity::log(Auth::user()->name . ' Add customer:' . $request->name);
     return redirect('admin/customers');
 }
开发者ID:shihqi,项目名称:fms,代码行数:20,代码来源:CustomerController.php

示例7: update

 /**
  * @param \App\Models\Customer $customer
  * @param string $action
  * @param int $beans_changed
  */
 protected function update(Customer $customer, $action, $beans_changed)
 {
     if ($action == AppConstant::BEAN_ACTION_CONSUME or $action == AppConstant::BEAN_ACTION_TRANSFER_CASH) {
         if ($beans_changed >= $customer->beans_total) {
             \EnterpriseAnalyzer::updateBasic(AnalyzerConstant::ENTERPRISE_BEAN, -$customer->beans_total);
             $customer->beans_total = 0;
         } else {
             \EnterpriseAnalyzer::updateBasic(AnalyzerConstant::ENTERPRISE_BEAN, -$beans_changed);
             $customer->beans_total -= $beans_changed;
         }
     } else {
         \EnterpriseAnalyzer::updateBasic(AnalyzerConstant::ENTERPRISE_BEAN, $beans_changed);
         $customer->beans_total += $beans_changed;
     }
     $customer->save();
 }
开发者ID:whplay,项目名称:ohmate-shop,代码行数:21,代码来源:BeanRecharger.php

示例8: register

 public function register(Request $request)
 {
     $c = new Customer();
     $c->id = $request->input('id');
     $c->code = $request->input('code');
     $c->openbalance = $request->input('openbalance');
     $c->creditlimit = $request->input('creditlimit');
     $c->name = $request->input('name');
     $c->preaddress = $request->input('preaddress');
     $c->peraddress = $request->input('peraddress');
     $c->phone = $request->input('phone');
     $c->email = $request->input('email');
     $c->fax = $request->input('fax');
     $c->url = $request->input('url');
     $c->userid = $request->input('userid');
     $c->save();
     return redirect('customers');
 }
开发者ID:richardkeep,项目名称:prct,代码行数:18,代码来源:CustomersController.php

示例9: 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

示例10: actionSignup

 public function actionSignup()
 {
     $model = new Customer();
     if ($model->load(Yii::$app->request->post())) {
         $request = Yii::$app->request->post('Customer');
         $username = $request['username'];
         $password = $request['password'];
         $verify = $request['verify'];
         if ($password != $verify) {
             return $this->redirect(['signup', 'error' => 'Mật khẩu không trùng khớp']);
         } else {
             if ($model->checkUserName($username) == FALSE) {
                 return $this->redirect(['signup', 'error' => 'Tên đăng nhập đã tồn tại']);
             } else {
                 $model->password = md5($password);
                 $model->save();
                 return $this->redirect(['signup', 'success' => 'OK']);
             }
         }
     }
     return $this->render('signup', ['model' => $model]);
 }
开发者ID:royutoan,项目名称:pianodanang,代码行数:22,代码来源:CustomerController.php

示例11: 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

示例12: actionCreateCustomerAndReservation

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

示例13: save

 function save(array $params)
 {
     $response = new ResponseEntity();
     try {
         DB::transaction(function () use(&$response, $params) {
             $user = User::find(1);
             $product = Product::find($params['product_id']);
             $cust = new Customer();
             $cust->first_name = $params['customer']['first_name'];
             $cust->last_name = $params['customer']['last_name'];
             $cust->phone_number = $params['customer']['phone_number'];
             $custCreated = $cust->save();
             if ($custCreated && $product && $user) {
                 $sale = new Sale();
                 $sale->user_id = $user->id;
                 $sale->product_id = $product->id;
                 $sale->customer_id = $cust->id;
                 $sale->date_sold = Carbon::createFromFormat('m/d/Y', $params['date_sold']);
                 $sale->remarks = isset($params['remarks']) ? $params['remarks'] : '';
                 $sale->order_number = $params['order_number'];
                 $sale->ninety_days = isset($params['ninety_days']) ?: 0;
                 $ok = $sale->save();
                 if ($ok) {
                     $response->setSuccess(true);
                     $response->setMessages(['Sale successfully created!']);
                 } else {
                     $response->setMessages(['Failed to create sale!']);
                 }
             } else {
                 $response->setMessages(['Entities not found']);
             }
         });
     } catch (\Exception $ex) {
         $response->setMessages(['Exception: ' . $ex->getMessage()]);
     }
     return $response;
 }
开发者ID:jenrielzany,项目名称:green-tracker,代码行数:37,代码来源:SaleServiceImpl.php

示例14: customer_register

 public function customer_register(Request $request)
 {
     if ($request->ajax() && $request->method() == 'POST') {
         $customer_code = $request->input('customer_code');
         $customer_name = $request->input('customer_name');
         $opening_balance = $request->input('opening_balance');
         $preaddress = $request->input('preaddress');
         $customer = new Customer();
         $customer->code = $customer_code;
         $customer->name = $customer_name;
         $customer->openbalance = $opening_balance;
         $customer->preaddress = $preaddress;
         $customer->save();
         Session::flash('new_customer_id', $customer->id);
         return response()->json(1);
     }
 }
开发者ID:richardkeep,项目名称:prct,代码行数:17,代码来源:PhysicalsaleController.php

示例15: sync_ekp_customer_init

 protected function sync_ekp_customer_init()
 {
     //更新没有code客户
     //update customers a inner join customer b on a.`name` = b.`name` set a.ekp_code = b.`code` where a.ekp_code is null
     //北京区域过滤规则
     $csts = DB::select('select * from customer where area_id = \'6b676aeb-a0ab-4e4e-b301-7a614cdff49d\' and LEFT(name,2) = \'北京\' and `name` not in (\'北京一组_费用权责发生制\',\'北京二组erp303sp4专属\',\'北京307sp4\')and LEFT(`name`,4) not in (select LEFT(`name`,4) from customers )');
     foreach ($csts as $cst) {
         if (!empty($cst)) {
             $customer = new Customer();
             $customer->name = $cst->name;
             $customer->uuid = Uuid::generate();
             $customer->ekp_code = $cst->code;
             $customer->area = '北京';
             $customer->source = 1;
             $customer->save();
             echo $this->print_log("客户 {$customer->name} 同步成功,客户code: {$cst->code} ");
         }
     }
     //成渝区域
     $csts = DB::select('select * from customer where area_id = \'d157cafa-85b5-4353-b583-4c584b424180\' and `name` not in (\'TEST\') and LEFT(`name`,4) not in (select LEFT(`name`,4) from customers )');
     foreach ($csts as $cst) {
         if (!empty($cst)) {
             $customer = new Customer();
             $customer->name = $cst->name;
             $customer->uuid = Uuid::generate();
             $customer->ekp_code = $cst->code;
             $customer->area = '成渝';
             $customer->source = 1;
             $customer->save();
             echo $this->print_log("客户 {$customer->name} 同步成功,客户code: {$cst->code} ");
         }
     }
     //广州福建长沙中山区域
     $csts = DB::select('select * from customer where area_id = \'570680b7-d751-4986-a83a-8aa4c6f01aec\' and `name` not in (\'TEST\') and LEFT(`name`,4) not in (select LEFT(`name`,4) from customers )');
     foreach ($csts as $cst) {
         if (!empty($cst)) {
             $customer = new Customer();
             $customer->name = $cst->name;
             $customer->uuid = Uuid::generate();
             $customer->ekp_code = $cst->code;
             //                $customer->area = '成渝';
             $customer->source = 1;
             $customer->save();
             echo $this->print_log("客户 {$customer->name} 同步成功,客户code: {$cst->code} ");
         }
     }
     //联营区域
     $csts = DB::select('select * from customer where area_id = \'ee0a764b-27d2-4bf5-af7b-6d196aa31c77\'  and `name` not in (\'TEST\') and LEFT(`name`,4) not in (select LEFT(`name`,4) from customers ) and LEFT(`name`,4) not in (\'标准产品\',\'产品验证\')');
     foreach ($csts as $cst) {
         if (!empty($cst)) {
             $customer = new Customer();
             $customer->name = $cst->name;
             $customer->uuid = Uuid::generate();
             $customer->ekp_code = $cst->code;
             $customer->area = '联营';
             $customer->source = 1;
             $customer->save();
             echo $this->print_log("客户 {$customer->name} 同步成功,客户code: {$cst->code} ");
         }
     }
     //上海区域
     $csts = DB::select('select * from customer where area_id = \'54fa8f61-55ff-4169-9fc2-8f63fdeb8ceb\'  and `name` not in (\'TEST\') and LEFT(`name`,4) not in (select LEFT(`name`,4) from customers ) and LEFT(`name`,4) not in (\'商城项目\')');
     foreach ($csts as $cst) {
         if (!empty($cst)) {
             $customer = new Customer();
             $customer->name = $cst->name;
             $customer->uuid = Uuid::generate();
             $customer->ekp_code = $cst->code;
             $customer->area = '上海';
             $customer->source = 1;
             $customer->save();
             echo $this->print_log("客户 {$customer->name} 同步成功,客户code: {$cst->code} ");
         }
     }
     //总部区域
     $csts = DB::select('select * from customer where area_id = \'b303ed9d-64ef-4f90-b6c6-c62819fbf387\'  and `name` not in (\'TEST\') and LEFT(`name`,4) not in (select LEFT(`name`,4) from customers ) and LEFT(`name`,4) not in (\'金威啤酒-粤海置地\',\'源动力\',\'星河\',\'万科\',\'招商\',\'明源公司\')');
     foreach ($csts as $cst) {
         if (!empty($cst)) {
             $customer = new Customer();
             $customer->name = $cst->name;
             $customer->uuid = Uuid::generate();
             $customer->ekp_code = $cst->code;
             $customer->area = '总部深圳';
             $customer->source = 1;
             $customer->save();
             echo $this->print_log("客户 {$customer->name} 同步成功,客户code: {$cst->code} ");
         }
     }
 }
开发者ID:kunta0514,项目名称:laravel,代码行数:89,代码来源:SyncCustomer.php


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