Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. Spark::freeTeamPlan('DIY Free','test_1234diyfree')
  2. ->features($diyFree)
  3. ->yearly()
  4. ->attributes([
  5. 'planid'=>'plan_DIYMFree',
  6. 'free'=>1,
  7. 'category' => 'all',
  8. ])
  9. ->maxTeamMembers(3);
  10.  
  11. class VerifyTeamIsSubscribed
  12. {
  13. /**
  14. * Verify the incoming request's current team has a subscription.
  15. *
  16. * @param IlluminateHttpRequest $request
  17. * @param Closure $next
  18. * @param string $subscription
  19. * @param string $plan
  20. * @return IlluminateHttpResponse
  21. */
  22. public function handle($request, $next, $subscription = 'default', $plan = null)
  23. {
  24. if ($this->subscribed($request->user(), $subscription, $plan, func_num_args() === 2)) {
  25. return $next($request);
  26. }
  27.  
  28. return $request->ajax() || $request->wantsJson()
  29. ? response('Subscription Required.', 402)
  30. : redirect('/settings/'.Spark::teamsPrefix().'/'.$request->user()->currentTeam->id.'#/subscription');
  31. }
  32.  
  33. /**
  34. * Determine if the given user's current team is subscribed to the given plan.
  35. *
  36. * @param IlluminateContractsAuthAuthenticatable $user
  37. * @param string $subscription
  38. * @param bool $plan
  39. * @param bool $defaultSubscription
  40. * @return bool
  41. */
  42. protected function subscribed($user, $subscription, $plan, $defaultSubscription)
  43. {
  44. if (! $user || ! $user->currentTeam) {
  45. return false;
  46. }
  47.  
  48. return ($defaultSubscription && $user->currentTeam->onGenericTrial()) ||
  49. $user->currentTeam->subscribed($subscription, $plan);
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement