feat: Add plan features and gating middleware#12
Conversation
# Conflicts: # src/CloudServiceProvider.php
Code Review SummaryThis PR adds subscription gating, Stripe integration via Cashier, and feature entitlement logic. It introduces a custom 🚀 Key Improvements
💡 Minor Suggestions
🚨 Critical Issues
|
| 'us' => [ | ||
| 'name' => 'United States', | ||
| 'currency' => 'USD', | ||
| 'monthly_price_id'=>'plan_id', // from stripe |
There was a problem hiding this comment.
Sensitive IDs and configuration values should not be hardcoded in the config file. They should be loaded via env() to ensure environment-specific values and better security.
| 'monthly_price_id'=>'plan_id', // from stripe | |
| 'monthly_price_id' => env('STRIPE_MONTHLY_PRICE_ID'), |
| */ | ||
| private function getCurrentChatMessageId(): ?int | ||
| { | ||
| foreach (debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT) as $frame) { |
There was a problem hiding this comment.
Using debug_backtrace for business logic (idempotency) is highly fragile and a performance anti-pattern. If the job class is renamed or the call stack changes, token consumption will fail. Pass the messageId explicitly to the consume method instead.
| foreach (debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT) as $frame) { | |
| // Pass message context explicitly in the consume signature if possible. | |
| return null; |
| { | ||
| Schema::create('subscriptions', function (Blueprint $table) { | ||
| $table->id(); | ||
| $table->foreignId('user_id')->constrained('billing_customers')->cascadeOnDelete(); |
There was a problem hiding this comment.
The foreign key references billing_customers, but the migration name suggests it's linked to the user_id. Ensure consistency with Laravel Cashier expectations where the billable model is typically the User model directly, or explicitly define the owner relationship.
| $table->foreignId('user_id')->constrained('billing_customers')->cascadeOnDelete(); | |
| $table->foreignId('user_id')->constrained('users')->cascadeOnDelete(); |
Fixes #8
Depends on #11