## New Features - Email notifications for overdue and upcoming payments - User preferences page for notification settings - Daily scheduler to send alerts at user-configured time - Smart analysis: payable items, transfer suggestions between accounts ## Backend - Migration for user_preferences table - SendDuePaymentsAlert Artisan command - DuePaymentsAlert Mailable with HTML/text templates - UserPreferenceController with test-notification endpoint - Scheduler config for notify:due-payments command ## Frontend - Preferences.jsx page with notification toggle - API service for preferences - Route and menu link for settings - Translations (PT-BR, EN, ES) ## Server - Cron configured for Laravel scheduler Version: 1.44.5
42 lines
939 B
PHP
42 lines
939 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class UserPreference extends Model
|
|
{
|
|
protected $fillable = [
|
|
'user_id',
|
|
'notify_due_payments',
|
|
'notify_due_payments_time',
|
|
'notify_due_payments_email',
|
|
'language',
|
|
'timezone',
|
|
'currency',
|
|
];
|
|
|
|
protected $casts = [
|
|
'notify_due_payments' => 'boolean',
|
|
// notify_due_payments_time is stored as TIME in DB, no cast needed
|
|
];
|
|
|
|
/**
|
|
* Get the user that owns the preferences.
|
|
*/
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
/**
|
|
* Get the email to send notifications to.
|
|
* Falls back to user's email if not set.
|
|
*/
|
|
public function getNotificationEmail(): string
|
|
{
|
|
return $this->notify_due_payments_email ?? $this->user->email;
|
|
}
|
|
}
|