コード例 #1
0
ファイル: orders.php プロジェクト: mehulsbhatt/volcano
 public function action_index()
 {
     $args = array('seller' => Seller::active());
     $pagination = Pagination::forge('customer_pagination', array('total_items' => Service_Customer_Order::count($args)));
     $orders = Service_Customer_Order::find(array_merge($args, array('offset' => $pagination->offset, 'limit' => $pagination->per_page, 'order_by' => array('updated_at' => 'desc'))));
     $this->view->orders = $orders;
     $this->view->pagination = $pagination;
 }
コード例 #2
0
ファイル: orders.php プロジェクト: mehulsbhatt/volcano
 /**
  * Creates an order.
  *
  * @param int $customer_id Customer ID.
  *
  * @return void
  */
 public function post_index($customer_id = null)
 {
     $customer = $this->get_customer($customer_id);
     $validator = \Validation_Customer_Order::create($customer);
     if (!$validator->run()) {
         throw new HttpBadRequestException($validator->errors());
     }
     $data = $validator->validated();
     $order = \Service_Customer_Order::create($customer, $data['products'], $data['paymentmethod']);
     if (!$order) {
         throw new HttpServerErrorException();
     }
     $this->response($order);
 }
コード例 #3
0
ファイル: simulate.php プロジェクト: mehulsbhatt/volcano
 /**
  * Generates customers.
  *
  * @return void
  */
 protected static function customers()
 {
     $balances = array(0, 5, 10, 12.5, 24.3);
     $first_names = array('Daniel', 'Steve', 'Elon', 'Bill', 'Stephan', 'Olivia', 'Keithia', 'Caroline', 'Porschia', 'Marie');
     $last_names = array('Sposito', 'Manos', 'Myers', 'Jenkins', 'Gates', 'Jobs', 'Musk', 'Wyrick', 'Natalie', 'Stevens');
     $streets = array('Wisteria Ln', 'Pebble Creek Blvd', 'Bakerstreet Dr', 'Miranda Point', 'Infinite Loop');
     $cities = array('Oklahoma City', 'Phoenix', 'Palo Alto', 'Saigon', 'Caracas');
     $states = array('OK', 'NY', 'CA', 'WA', 'FL');
     $countries = array('US', 'VN', 'VE');
     $customers = array();
     for ($i = 1; $i <= self::TOTAL_CUSTOMERS; $i++) {
         $first_name = $first_names[array_rand($first_names)];
         $last_name = $last_names[array_rand($last_names)];
         // Random created_at between the begin date and now.
         $date = date("Y-m-d H:i:s", mt_rand(self::BEGIN_DATETIME, time()));
         $customers[] = array('balance' => $balances[array_rand($balances)], 'contact' => array('first_name' => $first_name, 'last_name' => $last_name, 'email' => $first_name . '.' . $last_name . mt_rand(1, 100) . '@gmail.com', 'address' => mt_rand(1, 5000) . ' ' . $streets[array_rand($streets)], 'city' => $cities[array_rand($cities)], 'state' => $states[array_rand($states)], 'zip' => mt_rand(10000, 99999), 'country' => $countries[array_rand($countries)]), 'status' => mt_rand(1, 10) <= 8 ? 'active' : 'deleted', 'created_at' => $date);
     }
     foreach ($customers as $data) {
         $seller = self::$sellers[array_rand(self::$sellers)];
         $customer = \Service_Customer::create($seller, $data);
         // Create a payment method for the faux customer.
         $payment_method = \Service_Customer_Paymentmethod::create($customer, self::$gateway, array('contact' => $data['contact'], 'account' => array('provider' => 'Volcano', 'number' => '6011000000000012', 'expiration_month' => '12', 'expiration_year' => '5')));
         // Subscribe a random number of customers to a product option.
         if ($customer && mt_rand(1, 10) >= 5) {
             $option = self::$product_options[$seller->id][array_rand(self::$product_options[$seller->id])];
             $order = \Service_Customer_Order::create($customer, array($option->id => 'My ' . \Str::random('alpha', 5)), null, array('created_at' => $customer->created_at));
             // Reset the order's updated_at.
             self::updateUpdatedAt($order);
         }
         // Reset the models' updated_at.
         self::updateUpdatedAt($customer);
         foreach ($customer->products as $product) {
             self::updateUpdatedAt($product);
         }
     }
     \Cli::write('Customer Simulation Complete', 'green');
 }
コード例 #4
0
ファイル: orders.php プロジェクト: mehulsbhatt/volcano
 /**
  * Displays a customer's orders.
  *
  * @param int $customer_id Customer ID.
  *
  * @return void
  */
 public function action_index($customer_id = null)
 {
     $customer = $this->get_customer($customer_id);
     $this->view->customer = $customer;
     $this->view->orders = Service_Customer_Order::find(array('customer' => $customer));
 }