Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Spark::freeTeamPlan('DIY Free','test_1234diyfree')
- ->features($diyFree)
- ->yearly()
- ->attributes([
- 'planid'=>'plan_DIYMFree',
- 'free'=>1,
- 'category' => 'all',
- ])
- ->maxTeamMembers(3);
- class VerifyTeamIsSubscribed
- {
- /**
- * Verify the incoming request's current team has a subscription.
- *
- * @param IlluminateHttpRequest $request
- * @param Closure $next
- * @param string $subscription
- * @param string $plan
- * @return IlluminateHttpResponse
- */
- public function handle($request, $next, $subscription = 'default', $plan = null)
- {
- if ($this->subscribed($request->user(), $subscription, $plan, func_num_args() === 2)) {
- return $next($request);
- }
- return $request->ajax() || $request->wantsJson()
- ? response('Subscription Required.', 402)
- : redirect('/settings/'.Spark::teamsPrefix().'/'.$request->user()->currentTeam->id.'#/subscription');
- }
- /**
- * Determine if the given user's current team is subscribed to the given plan.
- *
- * @param IlluminateContractsAuthAuthenticatable $user
- * @param string $subscription
- * @param bool $plan
- * @param bool $defaultSubscription
- * @return bool
- */
- protected function subscribed($user, $subscription, $plan, $defaultSubscription)
- {
- if (! $user || ! $user->currentTeam) {
- return false;
- }
- return ($defaultSubscription && $user->currentTeam->onGenericTrial()) ||
- $user->currentTeam->subscribed($subscription, $plan);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement