當前位置: 首頁>>代碼示例>>PHP>>正文


PHP models\Customer類代碼示例

本文整理匯總了PHP中app\models\Customer的典型用法代碼示例。如果您正苦於以下問題:PHP Customer類的具體用法?PHP Customer怎麽用?PHP Customer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Customer類的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: checkSaleCredential

 private function checkSaleCredential(Customer $customer, $sale)
 {
     if ($sale = '1元專區') {
         return !$customer->hasPurchesedOneSale();
     }
     return true;
 }
開發者ID:whplay,項目名稱:ohmate-shop,代碼行數:7,代碼來源:OrderController.php

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

示例4: actionPayment

 public function actionPayment()
 {
     if (\Yii::$app->session->has('customer')) {
         $modelCustomer = new Customer();
         $infoCustomer = $modelCustomer->getInformation($_SESSION['customer']);
         $modelOrder = new Order();
         $modelOrderDetail = new OrderDetail();
         $modelProduct = new Product();
         $ids = array();
         foreach ($_SESSION['cart_items'] as $id => $quantity) {
             array_push($ids, $id);
         }
         $products = $modelProduct->getWithIDs($ids);
         if (\Yii::$app->request->post()) {
             $modelOrder->load(\Yii::$app->request->post());
             $modelOrder->save();
             $orderId = $modelOrder->id;
             foreach ($_SESSION['cart_items'] as $id => $quantity) {
                 $unitPrice = $modelProduct->getPrice($id) * $quantity;
                 \Yii::$app->db->createCommand()->insert('order_detail', ['orderId' => $orderId, 'productId' => $id, 'unitPrice' => $unitPrice, 'quantity' => $quantity])->execute();
             }
             \Yii::$app->session->remove('cart_items');
             return $this->redirect(['cart/index', 'success' => 'Thanh toán thành công! Chúng tôi sẽ liên hệ bạn trong thời gian sớm nhất! Xin cảm ơn!']);
         } else {
             return $this->render('payment', ['infoCustomer' => $infoCustomer, 'modelOrder' => $modelOrder, 'products' => $products]);
         }
     } else {
         $this->redirect(['customer/login', 'error' => 'Vui lòng đăng nhập trước khi thanh toán']);
     }
 }
開發者ID:royutoan,項目名稱:pianodanang,代碼行數:30,代碼來源:CartController.php

示例5: actionCreateMultipleModels

 public function actionCreateMultipleModels()
 {
     $models = [];
     $OK = true;
     if (isset($_POST['Customer'])) {
         foreach ($_POST['Customer'] as $postObj) {
             $customer = new Customer();
             $customer->attributes = $postObj;
             $isValid = $customer->validate();
             $OK = $OK && $isValid;
             $models[] = $customer;
         }
         if ($OK) {
             foreach ($models as $model) {
                 $model->save();
             }
             $this->redirect('customers/grid');
         }
     } else {
         for ($i = 0; $i < 3; $i++) {
             $models[] = new Customer();
         }
     }
     return $this->render('createMultipleModels', compact('models'));
 }
開發者ID:soanni,項目名稱:yii2news,代碼行數:25,代碼來源:CustomersController.php

示例6: create

 /**
  * O método precisa informar uma lista de produtos
  * @return {view}
  */
 public function create()
 {
     $stocks = Stock::all();
     $customers = Customer::all();
     $employees = Employee::all();
     return view('pages.new_sale', ['stocks' => $stocks, 'customers' => $customers, 'employees' => $employees]);
 }
開發者ID:bsampaio,項目名稱:LumenExperience,代碼行數:11,代碼來源:SaleController.php

示例7: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $role = Role::where('name', 'admin')->first();
     $customer = Customer::create(['name' => 'test']);
     $customer->user()->save(new User(['email' => 't@t.test', 'password' => bcrypt('testing')]));
     $customer->user->assignRole($role);
 }
開發者ID:RichardMarbach,項目名稱:mkdir,代碼行數:12,代碼來源:UserTableSeeder.php

示例8: index

	public function index(){
		$data = [
			'auth'=>false,
			'recentAdded'=>Customer::orderBy('created_at', 'desc')->take(5)->get()
		];
		return view('home', $data);
	}
開發者ID:nekoTheGreat,項目名稱:CustomerMgt,代碼行數:7,代碼來源:HomeController.php

示例9: getSearch

 public function getSearch(Request $request)
 {
     $q = $request->get('q');
     $limit = $request->get('limit', 5);
     $customers = Customer::where('mobile_phone', 'like', $q . '%')->with('addresses')->paginate($limit);
     return $customers;
 }
開發者ID:noodle-learns-programming,項目名稱:laravel,代碼行數:7,代碼來源:CustomerController.php

示例10: approveApplication

 public function approveApplication(Request $request)
 {
     $shop_card_application_id = $request->input('require_id');
     $application = ShopCardApplication::find($shop_card_application_id);
     $customer = Customer::find($application->customer_id);
     $card_type = $application->cardType;
     try {
         \DB::transaction(function () use($application, $customer, $card_type) {
             $customer_rows = \DB::table('customers')->where('id', $customer->id);
             $customer_rows->lockForUpdate();
             $customer_row = $customer_rows->first();
             if ($customer_row->beans_total < $card_type->beans_value * $application->amount) {
                 throw new NotEnoughBeansException();
             }
             $cards = \DB::table('shop_cards')->where('card_type_id', '=', $card_type->id)->whereNull('customer_id')->limit($application->amount);
             $cards->lockForUpdate();
             if ($cards->count() < $application->amount) {
                 throw new CardNotEnoughException();
             }
             $customer->minusBeansByHand($application->amount * $card_type->beans_value);
             $cards->update(['customer_id' => $customer->id, 'bought_at' => Carbon::now()]);
             $application->update(['authorized' => true]);
             return true;
         });
     } catch (CardNotEnoughException $e) {
         return '相應卡片不足,無法繼續。';
     } catch (NotEnoughBeansException $e) {
         return '用戶邁豆不足!';
     }
     return "操作成功!";
 }
開發者ID:whplay,項目名稱:ohmate-shop,代碼行數:31,代碼來源:CardApplicationController.php

示例11: index

 public function index()
 {
     $c = Customer::get();
     $bankaccount = Bankaccount::joining();
     $voucher = Voucher::orderBy('id', 'desc')->where('type', 5)->take(10)->get();
     return view('contravouchar', compact('bankaccount', 'c', 'voucher'));
 }
開發者ID:richardkeep,項目名稱:prct,代碼行數:7,代碼來源:ContravoucherController.php

示例12: detail

 /**
  * Display a customer
  *
  * @return Response
  */
 public function detail($id = null)
 {
     $result = \App\Models\Customer::id($id)->with(['sales', 'myreferrals', 'myreferrals.user'])->first();
     if ($result) {
         return new JSend('success', (array) $result->toArray());
     }
     return new JSend('error', (array) Input::all(), 'ID Tidak Valid.');
 }
開發者ID:ThunderID,項目名稱:SHOP-API,代碼行數:13,代碼來源:CustomerController.php

示例13: report

 public function report()
 {
     $s = Supplier::get();
     $c = Customer::get();
     $bankaccount = Bankaccount::joining();
     $voucher = Voucher::orderBy('id', 'desc')->take(10)->get();
     return view('ledger', compact('bankaccount', 'c', 's', 'voucher'));
 }
開發者ID:richardkeep,項目名稱:prct,代碼行數:8,代碼來源:CustomersledgerController.php

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

示例15: test

 public function test()
 {
     $customer = Customer::where('openid', 'oUS_vt3J8ClZx4q1wmx6VBJ1KfwQ')->firstOrFail();
     $end = new \DateTime(Carbon::now()->format('Y-m'));
     $begin = new \DateTime($customer->created_at->format('Y-m'));
     $month = \Helper::getDatePeriod($begin, $end);
     dd($month);
 }
開發者ID:whplay,項目名稱:ohmate-shop,代碼行數:8,代碼來源:TestController.php


注:本文中的app\models\Customer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。