Closed benferns closed 3 years ago
I've been doing some thinking on this and I can see how its a bit tough to know which model in particular (if its not the user). I'm not the most-experienced laravel coder, so I may be missing standardised approaches to this kind of problem.
Maybe an option to allow setting of the model via the route params, to allow the dev in question to link correctly? Or an overridable ->billableModel() method on User via a trait that returns the specific cashier model they want (though it could be awkward if the billable model is in no way linked to particular users)?
For now I've taken a hacky approach with my project, duplicated the controllers and replaced all $request->user() calls with $request->user()->currentTeam and that got me 95% of the way there since most of the Billable Model references are generic. (I suspect options for Team and User models would actually cover 80%+ of use-cases).
Thanks for the work on the project - its invaluable being able to move off of Spark while they are in limbo.
@60days How about configuring it directly in the service provider. Something like:
BillingPortal::setBillable(function ($request) {
return $request->user()->currentTeam; // $request->user() by default
});
I saw SubscriptionController.php references
$user = $request->user();
But noticed elsewhere the more generic Model class was used. Is there a way to configure the package to use the CASHIER_MODEL specified in the env vars?