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


PHP Spark::validateRegistrationsWith方法代码示例

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


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

示例1: customizeRegistration

 /**
  * Customize Spark's new user registration logic.
  *
  * @return void
  */
 protected function customizeRegistration()
 {
     Spark::validateRegistrationsWith(function (Request $request) {
         return ['name' => 'required|max:255', 'email' => 'required|email|unique:users', 'password' => 'required|confirmed|min:6', 'terms' => 'required|accepted'];
     });
     // Spark::createUsersWith(function (Request $request) {
     //     // Return New User Instance...
     // });
 }
开发者ID:edos-io,项目名称:dexter,代码行数:14,代码来源:SparkServiceProvider.php

示例2: customizeRegistration

 /**
  * Customize Spark's new user registration logic.
  *
  * @return void
  */
 protected function customizeRegistration()
 {
     if (Spark::basedInEU()) {
         Spark::validateRegistrationsWith(function (Request $request, $withSubscription = false) {
             $userRules = ['name' => 'required|max:255', 'email' => 'required|email|unique:users', 'password' => 'required|confirmed|min:6', 'terms' => 'required|accepted'];
             $addressRules = ['street' => 'required', 'city' => 'required', 'zip' => 'required', 'country' => 'required', 'vat_id' => 'vat_number'];
             return $withSubscription ? array_merge($userRules, $addressRules) : $userRules;
         });
     }
     // Spark::validateSubscriptionsWith(function (Request $request) {
     //     return [
     //         'plan' => 'required',
     //         'terms' => 'required|accepted',
     //         'stripe_token' => 'required',
     //     ];
     // });
     // Spark::createUsersWith(function (Request $request) {
     //     // Return New User Instance...
     // });
     /**
      * To comply with the EU VAT regulations we need to pass
      * the user's address, IP and company name to stripe.
      * This data will also be used for the invoices.
      */
     if (Spark::basedInEU()) {
         Spark::createSubscriptionsWith(function (Request $request, $user, $subscription) {
             /**
              * Apply tax rate from the given country.
              * If a valid VAT ID is given, the VAT
              * rate will be set to 0.
              */
             $user->setTaxForCountry($request->country, $request->has('vat_id'));
             $subscription->create($request->stripe_token, ['email' => $user->email, 'description' => $user->name, 'metadata' => ['ip' => $request->getClientIp(), 'company' => $request->company, 'vat_id' => $request->vat_id, 'tax_percent' => $user->getTaxPercent()]]);
         });
     }
     /**
      * Apply the tax rate of the customer to the invoice
      * when swapping plans.
      */
     if (Spark::basedInEU()) {
         Spark::swapSubscriptionsWith(function (Request $request, $user) {
             $user->subscription($request->plan)->maintainTrial()->prorate()->swap();
             $customer = $user->subscription()->getStripeCustomer();
             \Stripe\Invoice::create(['customer' => $customer->id, 'tax_percent' => $customer->metadata->tax_percent], $user->getStripeKey())->pay();
         });
     }
 }
开发者ID:airlst,项目名称:spark,代码行数:52,代码来源:SparkServiceProvider.php


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