Add subscription tiers, notification preferences, and logging infrastructure
- Add database migrations for plans, subscriptions, notification preferences, and notification log tables - Implement DispatchUserNotificationJob to handle channel resolution, daily limits, and logging (sent/tier_restricted/daily_limit) - Add SendScheduledWhatsAppJob for scheduled notification delivery - Create PlanFeatures service to resolve tier capabilities, check daily limits, and validate fuel
This commit is contained in:
49
app/Models/UserNotificationPreference.php
Normal file
49
app/Models/UserNotificationPreference.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Database\Factories\UserNotificationPreferenceFactory;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class UserNotificationPreference extends Model
|
||||
{
|
||||
/** @use HasFactory<UserNotificationPreferenceFactory> */
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'channel',
|
||||
'fuel_type',
|
||||
'enabled',
|
||||
];
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function scopeEnabled(Builder $query): void
|
||||
{
|
||||
$query->where('enabled', true);
|
||||
}
|
||||
|
||||
public function scopeForChannel(Builder $query, string $channel): void
|
||||
{
|
||||
$query->where('channel', $channel);
|
||||
}
|
||||
|
||||
public function scopeForFuelType(Builder $query, string $fuelType): void
|
||||
{
|
||||
$query->where('fuel_type', $fuelType);
|
||||
}
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'enabled' => 'boolean',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user