Integrating Multi-Tenancy with Laravel Spark: Handling Subscriptions and Trial Periods
What I am trying to do:
I am integrating FilamentPHP's multi-tenancy features with Laravel Spark. I want to ensure that the application correctly handles trial periods as configured in Laravel Spark. This solution works.
What I did:
I implemented a custom middleware named
CheckTenantSubscription
to check whether a tenant has an active subscription or is within their trial period, redirecting them to the billing page if neither condition is met. In this middleware, I used Filament::getTenant()
to retrieve the tenant's information, and then proceeded to check their subscription status and trial period against the current date and time.
My issue/the error:
Using FilamentPHP's ->requiresTenantSubscription() seems to ignore Laravel Spark’s trial period. I expected it to consider the trial period automatically during subscription checks. In my middleware, I’ve explicitly handled trial and subscription checks. However, I’m uncertain if this aligns with FilamentPHP standards, especially when integrated with Laravel Spark. I am looking for guidance on whether there is a standard or more "Filament" way to handle this scenario.
Code:
2 Replies
@Donnell Wyche did you ever find a solution for this?
I created a OnTrialMiddel Middleware. My specific application logic is missing, but you can see what I did here. Not sure if it's the best FilamentPHP approach, but like everything else, it works.