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


PHP Spark::plans方法代码示例

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


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

示例1: __construct

 /**
  * Create a new authentication controller instance.
  *
  * @param  \Laravel\Spark\Contracts\Repositories\UserRepository  $users
  * @param  \Laravel\Spark\Contracts\Repositories\TeamRepository  $teams
  * @return void
  */
 public function __construct(UserRepository $users, TeamRepository $teams)
 {
     $this->users = $users;
     $this->teams = $teams;
     $this->plans = Spark::plans();
     $this->middleware('guest', ['except' => 'getLogout']);
 }
开发者ID:ncpope,项目名称:spark,代码行数:14,代码来源:AuthController.php

示例2: createSubscriptionOnStripe

 /**
  * Create the subscription on Stripe.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Illuminate\Contracts\Auth\Authenticatable  $user
  * @return void
  */
 protected function createSubscriptionOnStripe(Request $request, $user)
 {
     $plan = Spark::plans()->find($request->plan);
     $subscription = $user->subscription($plan->id);
     if ($plan->hasTrial()) {
         $subscription->trialFor(Carbon::now()->addDays($plan->trialDays));
     }
     if ($request->coupon) {
         $subscription->withCoupon($request->coupon);
     }
     $subscription->create($request->stripe_token, ['email' => $user->email]);
 }
开发者ID:mastashake08,项目名称:laravel-spark-archive,代码行数:19,代码来源:UserRepository.php

示例3: changeSubscriptionPlan

 /**
  * Change the user's subscription plan.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function changeSubscriptionPlan(Request $request)
 {
     $this->validate($request, ['plan' => 'required']);
     $plan = Spark::plans()->find($request->plan);
     if ($plan->price() === 0) {
         $this->cancelSubscription();
     } else {
         Auth::user()->subscription($request->plan)->maintainTrial()->prorate()->swapAndInvoice();
     }
     event(new SubscriptionPlanChanged(Auth::user()));
     return $this->users->getCurrentUser();
 }
开发者ID:xxlv,项目名称:spark,代码行数:18,代码来源:SubscriptionController.php

示例4: update

 /**
  * Update the subscription for the user.
  *
  * @param  \Laravel\Spark\Http\Requests\UpdateSubscriptionRequest  $request
  * @return Response
  */
 public function update(UpdateSubscriptionRequest $request)
 {
     $plan = Spark::plans()->where('id', $request->plan)->first();
     // This method is used both for updating subscriptions and for resuming cancelled
     // subscriptions that are still within their grace periods as this swap method
     // will be used for either of these situations without causing any problems.
     if ($plan->price === 0) {
         return $this->destroy($request);
     } else {
         $request->user()->subscription()->swap($request->plan);
     }
     event(new SubscriptionUpdated($request->user()->fresh()));
 }
开发者ID:defenestrator,项目名称:groid,代码行数:19,代码来源:PlanController.php

示例5: changeSubscriptionPlan

 /**
  * Change the user's subscription plan.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function changeSubscriptionPlan(Request $request)
 {
     $this->validate($request, ['plan' => 'required']);
     $plan = Spark::plans()->find($request->plan);
     if ($plan->price() === 0) {
         $this->cancelSubscription();
     } elseif (Spark::$swapSubscriptionsWith) {
         $this->callCustomUpdater(Spark::$swapSubscriptionsWith, $request, [Auth::user()]);
     } else {
         Auth::user()->subscription('main')->swap($request->plan);
     }
     event(new SubscriptionPlanChanged(Auth::user()));
     return $this->users->getCurrentUser();
 }
开发者ID:mzkmzk,项目名称:spark,代码行数:20,代码来源:SubscriptionController.php

示例6: createSubscriptionOnStripe

 /**
  * Create the subscription on Stripe.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Illuminate\Contracts\Auth\Authenticatable  $user
  * @param  \Stripe\Customer|null  $stripeCustomer
  * @return void
  */
 public function createSubscriptionOnStripe(Request $request, $user, $stripeCustomer = null)
 {
     $plan = Spark::plans()->find($request->plan);
     $subscription = $user->subscription($plan->id);
     if ($plan->hasTrial() && $stripeCustomer === null) {
         $subscription->trialFor(Carbon::now()->addDays($plan->trialDays));
     }
     if ($request->coupon) {
         $subscription->withCoupon($request->coupon);
     }
     if (Spark::$createSubscriptionsWith) {
         $this->callCustomUpdater(Spark::$createSubscriptionsWith, $request, [$user, $subscription, $stripeCustomer]);
     } else {
         $this->createDefaultSubscription($request, $user, $subscription, $stripeCustomer);
     }
 }
开发者ID:noikiy,项目名称:spark-1,代码行数:24,代码来源:UserRepository.php

示例7: createSubscriptionOnStripe

 /**
  * Create the subscription on Stripe.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Illuminate\Contracts\Auth\Authenticatable  $user
  * @return void
  */
 public function createSubscriptionOnStripe(Request $request, $user)
 {
     $plan = Spark::plans()->find($request->plan);
     $subscription = $user->newSubscription('main', $plan->id);
     if ($plan->hasTrial() && !$user->stripe_id) {
         $subscription->trialDays($plan->trialDays);
     }
     if ($request->coupon) {
         $subscription->withCoupon($request->coupon);
     }
     if (Spark::$createSubscriptionsWith) {
         $this->callCustomUpdater(Spark::$createSubscriptionsWith, $request, [$user, $subscription, $stripeCustomer]);
     } else {
         $subscription->create($request->stripe_token);
     }
 }
开发者ID:mzkmzk,项目名称:spark,代码行数:23,代码来源:UserRepository.php

示例8: validatePlanEligibility

 /**
  * Validate that the plan is eligible based on team restrictions.
  *
  * @param  \Illuminate\Validation\Validator  $valdiator
  * @return void
  */
 protected function validatePlanEligibility($validator)
 {
     $plan = Spark::plans()->where('id', $this->plan)->first();
     // If the desired plan is free, we will always need to let the user switch to that
     // plan since we'll want the user to always be able to cancel this subscription
     // without preventing them. So, we will just return here if it's a free plan.
     if (!$plan || $plan->price === 0) {
         return;
     }
     $this->callCustomCallback($validator, $plan);
     // If the user is ineligible for a plan based on their team member or collaborator
     // count, we will prevent them switching to this plan and send an error message
     // back to the client informing them of this limitation and they can upgrade.
     if (!$this->userIsEligibleForPlan($plan)) {
         $validator->errors()->add('plan', trans('spark::validation.eligibility'));
     }
 }
开发者ID:defenestrator,项目名称:groid,代码行数:23,代码来源:DeterminesPlanEligibility.php

示例9: getCouponForUser

 /**
  * Get the current coupon for the authenticated user.
  *
  * Used to display current discount on settings -> subscription tab.
  *
  * @return \Illuminate\Http\Response
  */
 public function getCouponForUser()
 {
     Stripe::setApiKey(config('services.stripe.secret'));
     if (count(Spark::plans()) === 0) {
         abort(404);
     }
     try {
         $customer = StripeCustomer::retrieve(Auth::user()->stripe_id);
         if ($customer->discount) {
             return response()->json(Coupon::fromStripeCoupon(StripeCoupon::retrieve($customer->discount->coupon->id)));
         } else {
             abort(404);
         }
     } catch (Exception $e) {
         abort(404);
     }
 }
开发者ID:mastashake08,项目名称:laravel-spark-archive,代码行数:24,代码来源:SubscriptionController.php

示例10: subscription

 /**
  * Get the tab configuration for the "subscription" tab.
  *
  * @param  bool  $force
  * @return \Laravel\Spark\Ux\Settings\Tab|null
  */
 public function subscription($force = false)
 {
     return new Tab('Subscription', 'spark::settings.tabs.subscription', 'fa-credit-card', function () use($force) {
         return count(Spark::plans()->paid()) > 0 || $force;
     });
 }
开发者ID:Braunson,项目名称:spark,代码行数:12,代码来源:DashboardTabs.php

示例11: plan

 /**
  * Get the full plan array for the specified plan.
  *
  * @return \Laravel\Spark\Plan|null
  */
 public function plan()
 {
     if ($this->plan) {
         return Spark::plans()->where('id', $this->plan)->first();
     }
 }
开发者ID:defenestrator,项目名称:groid,代码行数:11,代码来源:RegisterRequest.php

示例12: all

 /**
  * Get the all of the plans defined for the appliation.
  *
  * @return Response
  */
 public function all()
 {
     return response()->json(Spark::plans());
 }
开发者ID:defenestrator,项目名称:groid,代码行数:9,代码来源:PlanController.php

示例13: availablePlans

 /**
  * Get the available billing plans for the given entity.
  *
  * @return \Illuminate\Support\Collection
  */
 public function availablePlans()
 {
     return Spark::plans();
 }
开发者ID:defenestrator,项目名称:groid,代码行数:9,代码来源:Billable.php


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