Add tier feature design spec, annual billing, fuel type normalization, and admin subscription management
- Add comprehensive tier feature matrix spec defining Free/Basic/Plus/Pro capabilities across recommendations, predictions, history, logs, tools, and family sharing - Add `stripe_price_id_annual` column to plans table and rename existing column to `stripe_price_id_monthly` - Normalize legacy fuel type aliases (petrol→e10, diesel→b7_standard) in users table - Implement BillingController with checkout, portal, success/cancel routes supporting monthly/annual cadence - Add admin subscription assignment in Filament user edit page with admin-granted subscription support - Add DowngradeUserOnSubscriptionDeleted listener to disable WhatsApp/SMS preferences on subscription cancellation - Add MissedNotificationsOverview widget to Filament user detail page - Add PollFuelPricesTest covering auto-refresh scenarios - Add PriceReliability enum with reliability classification based on price age - Add fuelTypes.js constants file exporting FUEL_TYPES from window global
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\UserResource\Widgets;
|
||||
|
||||
use App\Models\NotificationLog;
|
||||
use App\Models\User;
|
||||
use Filament\Widgets\StatsOverviewWidget;
|
||||
use Filament\Widgets\StatsOverviewWidget\Stat;
|
||||
|
||||
class MissedNotificationsOverview extends StatsOverviewWidget
|
||||
{
|
||||
public ?User $record = null;
|
||||
|
||||
protected function getStats(): array
|
||||
{
|
||||
if ($this->record === null) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$userId = $this->record->id;
|
||||
|
||||
$missedTodayByChannel = fn (string $channel): int => NotificationLog::where('user_id', $userId)
|
||||
->where('channel', $channel)
|
||||
->where('sent', false)
|
||||
->whereDate('created_at', today())
|
||||
->count();
|
||||
|
||||
$missedThisMonth = NotificationLog::where('user_id', $userId)
|
||||
->where('sent', false)
|
||||
->whereMonth('created_at', now()->month)
|
||||
->whereYear('created_at', now()->year)
|
||||
->count();
|
||||
|
||||
return [
|
||||
Stat::make('SMS missed today', $missedTodayByChannel('sms'))
|
||||
->color($missedTodayByChannel('sms') > 0 ? 'warning' : 'gray'),
|
||||
Stat::make('WhatsApp missed today', $missedTodayByChannel('whatsapp'))
|
||||
->color($missedTodayByChannel('whatsapp') > 0 ? 'warning' : 'gray'),
|
||||
Stat::make('Total missed this month', $missedThisMonth)
|
||||
->color($missedThisMonth > 0 ? 'warning' : 'gray'),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user