订阅控制器
class SubscriptionController extends Controller
{
public function create(Request $request, Plan $plan)
{
$plan = Plan::findOrFail($request->get('plan'));
$stripeToken = $request->stripeToken;
$user = $request->user();
$stripeplan = $request->stripe_plan;
$subs = Subscriptions::findOrFail($request->get('plan'));
$planid = $request->plan;
$user->newSubscription($user->name, $planid)->create($stripeToken);
return redirect()->route('home')->with('success', 'Your plan subscribed successfully');
}
}
收银员的SubscriptionBuilder
public function create($token = null, array $options = [])
{
$customer = $this->getStripeCustomer($token, $options);
$subscription = $customer->subscriptions->create($this->buildPayload());
if (in_array($subscription->status, ['incomplete', 'incomplete_expired'])) {
$subscription->cancel();
throw SubscriptionCreationFailed::incomplete($subscription);
}
if ($this->skipTrial) {
$trialEndsAt = null;
} else {
$trialEndsAt = $this->trialExpires;
}
return $this->owner->subscriptions()->create([
'name' => $this->name,
'stripe_id' => $subscription->id,
'stripe_plan' => $this->plan,
'quantity' => $this->quantity,
'trial_ends_at' => $trialEndsAt,
'ends_at' => null,
]);
}
现在我想覆盖创建控制器功能。我想使用控制器删除数量,试用期结束。请帮助我