Couldn't you just set the free trial days to some huge number?
https://spark.laravel.com/docs/6.0/billing#no-credit-card-up-front
I want my Spark application to offer a free plan that users will be "subscribed" to by default. Not a trial (aka, so no expiration), and I do not want to require payment information up front.
If users want to have access to "premium" features of the application, they may choose to subscribe to a paid plan.
Does anybody know how to implement something like this?
Couldn't you just set the free trial days to some huge number?
https://spark.laravel.com/docs/6.0/billing#no-credit-card-up-front
@topvillas I suppose I could. But is that really the best / only way?
Why are you even making a subscription 'plan' at all if the content is free? Surely all you require from the user at that point is an active membership (i.e confirmed email), and not a subscription to a plan.
It sounds like you are making more work for yourself than is actually needed.
How about, don't put those pages behind any kind of gateway check at all. They'll be visible to anyone using your app/website.
I am having the same issue where I want to offer a free plan that will have ads for example, and some paid subscriptions that will not have the ads and potentially more features.
Setting the trial number to some large number works but then if the user wanted to subscribe, they would still have the trial days to see out so I am not sure that is best solution.
I have also tried adding free plan stuff that comes out of the box the Spark::freePlan() etc, but that just redirects the user to subscribe so I am not sure what is wrong there.
Bit confused with this one.
Me too, but I'm going to just treat most of my routes constrained through middleware as "auth". So if a user is registered but not subscribed, they will be able to access all pages (but with ads). On those same pages, I'll have some checks to see if a user is registered. So like this:
@unless(Auth::user()->subscribed())
// Show ads
@endunless
Why not make a free plan (price 0) and just use
https://spark.laravel.com/docs/6.0/billing#no-credit-card-up-front
I know this is an older post, but figured I'd contribute...
We just left everything the same but added the override to force the trial timestamp field (trial_ends_at) to null.
Example added to the bottom of the booted() method in the SparkServiceProvider.php:
Spark::createUsersWith(function ($request) {
$user = Spark::user();
$data = $request->all();
$user->forceFill([
'name' => $data['name'],
'email' => $data['email'],
'location' => $data['location'],
'referral' => ($data['referral'] !== 'undefined' && !empty($data['referral'])) ? $data['referral'] : '',
'password' => bcrypt($data['password']),
'last_read_announcements_at' => Carbon::now(),
'trial_ends_at' => null,
])->save();
return $user;
});
Just to add to @nateritter's reply since it helped me find what I needed, if you want to achieve the same sort of thing but you're using Team Billing, do something like this:
Spark::swap('TeamRepository@create', function ($user, array $data) {
$attributes = [
'owner_id' => $user->id,
'name' => $data['name'],
'trial_ends_at' => null,
];
if (Spark::teamsIdentifiedByPath()) {
$attributes['slug'] = $data['slug'];
}
return Spark::team()->forceCreate($attributes);
});
I have made a tutorial with Laravel Spark Next on my blog. No credit card required and it's very simple.
https://blog.akbal.dev/how-to-build-a-free-plan-in-laravel-spark
Please or to participate in this conversation.