/**
  * Validate that the plan is eligible based on team restrictions.
  *
  * @param  \Illuminate\Validation\Validator  $valdiator
  * @return void
  */
 protected function validatePlanEligibility($validator)
 {
     $plan = Spark::teamPlans()->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->teamIsEligibleForPlan($this->route('team'), $plan)) {
         $validator->errors()->add('plan', 'This team has too many team members for the selected plan.');
     }
 }
Ejemplo n.º 2
0
 /**
  * Get the available billing plans for the given entity.
  *
  * @return \Illuminate\Support\Collection
  */
 public function availablePlans()
 {
     return Spark::teamPlans();
 }
Ejemplo n.º 3
0
 /**
  * Get the all of the team plans defined for the appliation.
  *
  * @return Response
  */
 public function all()
 {
     return response()->json(Spark::teamPlans());
 }
 /**
  * Get the Spark plan associated with the request.
  *
  * @return \Laravel\Spark\Plan
  */
 public function plan()
 {
     return Spark::teamPlans()->where('id', $this->plan)->first();
 }