本文整理汇总了PHP中Illuminate\Contracts\Auth\Authenticatable::subscription方法的典型用法代码示例。如果您正苦于以下问题:PHP Authenticatable::subscription方法的具体用法?PHP Authenticatable::subscription怎么用?PHP Authenticatable::subscription使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Contracts\Auth\Authenticatable
的用法示例。
在下文中一共展示了Authenticatable::subscription方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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]);
}
示例2: 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);
}
}