I am using Laravel Spark Next and I am trying to create a free plan. My application is charging users "Per seat" (# of projects)
My application, however, will always have one free project included. That means I need to offer two plans: one free and one paid
In my SparkServiceProvider, I have added this:
Spark::billable(User::class)->chargePerSeat('lejemål', function (User $billable) {
$projects = return $billable->projects()->count();
//The first project is always free.
return match ($projects) {
0, 1 => 0,
default => $leases,
};
});
As far as I understand, the "chargePerSeat" method simply calculate the price to charge the user. So in this case, if the user have 0 or 1 project and chooses to subscribe, the price to be paid is zero (as it should be).
However, I am trying to understand how a free plan should work. In the classic Spark, we could define a "free plan" in the configuration.
When users are creating projects, I have added the subscribed
middleware as per the documentation:
Route::get('projects/create', CreateProject::class)
->name('projects.create')
->middleware('subscribed');
It seems like this middleware simply checks if there is an active subscription or not. If there is not, it redirects the user to the /billing
page. However, if users simply just want to stay on the free plan, he/she should not need to create an active subscription.
How can I provide a "free plan" using Laravel Spark Next?