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


PHP Accounts::get_balance方法代码示例

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


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

示例1: define

 function define()
 {
     // Fields.
     $this->fields = array('id', 'name', 'email', 'password', 'roles', 'ip_address', 'date_created', 'date_updated', 'first_name' => function ($account) {
         return Accounts::get_first_name($account);
     }, 'last_name' => function ($account) {
         return Accounts::get_last_name($account);
     }, 'orders' => function ($account) {
         return get("/orders", array('account_id' => $account['id']));
     }, 'billing' => function ($account) {
         return $account['billing'] ?: $account['last_order']['billing'];
     }, 'shipping' => function ($account) {
         return $account['shipping'] ?: $account['last_order']['shipping'];
     }, 'order_count' => function ($account) {
         return get("/orders", array(':count' => true, 'account_id' => $account['id']));
     }, 'last_order' => function ($account) {
         return Accounts::get_last_complete_order($account);
     }, 'credits' => function ($account) {
         return get("/payments", array('method' => 'credit', 'account_id' => $account['id'], 'limit' => null, 'order' => 'date_created ASC'));
     }, 'balance' => function ($account) {
         return Accounts::get_balance($account);
     }, 'has_role' => function ($account) {
         foreach ((array) $account['roles'] as $key => $val) {
             $roles[is_string($val) ? $val : $key] = true;
         }
         return $roles;
     }, 'discounts' => function ($account) {
         return get("/discounts", array('account_role' => $account['roles'], 'account_id' => $account['id'], 'is_valid' => true));
     });
     // Search fields.
     $this->search_fields = array('id', 'name', 'email');
     // Email slug.
     $this->slug_pk = 'email';
     // Indexes.
     $this->indexes = array('id' => 'unique', 'email' => 'unique');
     // Validate.
     $this->validate = array('required' => array('name', 'email', 'password'), 'email-address' => array('email'), 'unique' => array('email'), 'length' => array('password' => array('min' => 4)));
     // Event binds.
     $this->binds = array('GET' => function ($event, $model) {
         $params =& $event['data'];
         // E-mail slugs need to be specially url decoded.
         if ($event['id'] && !is_numeric($event['id'])) {
             $event['id'] = urldecode($event['id']);
             $event['id'] = strtolower($event['id']);
             $event['id'] = str_replace(' ', '+', trim($event['id']));
         }
         // E-mails are case-insensitive.
         if ($params['email']) {
             $params['email'] = strtolower($params['email']);
         }
         // Approve login?
         if ($params['login']) {
             return $model->login($params['login'], $params['role']);
         }
     }, 'POST' => function ($event, $model) {
         $data =& $event['data'];
         // Default name.
         if (!isset($data['name']) && isset($data['email'])) {
             list($name) = explode('@', $data['email']);
             $name = preg_replace('/[^\\w]/', ' ', $name);
             $data['name'] = ucwords($name);
         }
         // Auto hash password?
         if ($data['password']) {
             $data['password'] = $model->hash_password($data['password']);
         } elseif ($data['password_hash']) {
             $data['password'] = $data['password_hash'];
             unset($data['password_hash']);
         }
     }, 'PUT' => function ($event, $model) {
         $data =& $event['data'];
         // Update existing?
         if ($account = $model->get($event['id'])) {
             // Update default billing?
             if ($data['billing']) {
                 $data['billing'] = array_merge((array) $account['billing'], (array) $data['billing']);
                 $data['billing']['default'] = true;
             }
             // Update default shipping?
             if ($data['shipping']) {
                 $data['shipping'] = array_merge((array) $account['shipping'], (array) $data['shipping']);
                 $data['shipping']['default'] = true;
             }
             // Reset password?
             if ($data['password_reset']) {
                 $data['password'] = $model->hash_password($data['password_reset']);
                 unset($data['password_reset']);
             } elseif ($data['password_hash']) {
                 $data['password'] = $data['password_hash'];
                 unset($data['password_hash']);
             } else {
                 // Password can't be updated arbitrarily.
                 unset($data['password']);
             }
         }
     }, 'POST, PUT' => function ($event, $model) {
         $data =& $event['data'];
         // E-mails are case-insensitive.
         if ($data['email']) {
             $data['email'] = strtolower($data['email']);
//.........这里部分代码省略.........
开发者ID:kfuchs,项目名称:fwdcommerce,代码行数:101,代码来源:Accounts.php


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