Jan 13, 2017
0
Level 12
How does Spark make this closure work?
Spark has an interaction to constrain access to a user's plan, like this:
Spark::checkPlanEligibilityUsing(function ($user, $plan) {
if ($plan->name == 'pro' && count($user->todos) > 20) {
return false;
}
});
https://spark.laravel.com/docs/3.0/billing#constraining-access-to-plans
I want to implement a similar feature, but I'm at a loss as to how Spark/Laravel automatically resolves the current $user and $plan into that closure.
Could anyone clear this up for me?
I guess I need to know how you register closures in general.
Thanks!
Please or to participate in this conversation.