- Implement EmailNotifier for sending batch and test notifications via email. - Implement TelegramNotifier for sending batch and test notifications via Telegram. - Implement WahaNotifier for sending batch and test notifications via WhatsApp using WAHA API. - Create migration for client_categories table and update clients table to include category_id. - Create migration for notification_settings table to manage notification configurations. - Add ClientCategorySeeder to populate default client categories. - Create manifest.json for PWA support. - Implement service worker (sw.js) for caching static assets and offline support. - Add edit event view for modifying scheduled events. - Create search results view for displaying search queries. - Develop notification settings view for configuring notification channels and triggers.
54 lines
1.8 KiB
PHP
54 lines
1.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class NotificationSetting extends Model
|
|
{
|
|
protected $fillable = [
|
|
'name', 'channel', 'config', 'triggers',
|
|
'is_enabled', 'notify_before_hours',
|
|
];
|
|
|
|
protected $casts = [
|
|
'config' => 'array',
|
|
'triggers' => 'array',
|
|
'is_enabled' => 'boolean',
|
|
'notify_before_hours' => 'integer',
|
|
];
|
|
|
|
// ── Channel icons/labels ─────────────────────────────────────
|
|
|
|
public static array $channelMeta = [
|
|
'email' => ['icon' => '✉️', 'label' => 'Email', 'color' => '#AEC6CF'],
|
|
'telegram' => ['icon' => '✈️', 'label' => 'Telegram', 'color' => '#E8D5F5'],
|
|
'whatsapp' => ['icon' => '💬', 'label' => 'WhatsApp', 'color' => '#B5EAD7'],
|
|
];
|
|
|
|
public function getChannelIconAttribute(): string
|
|
{
|
|
return static::$channelMeta[$this->channel]['icon'] ?? '🔔';
|
|
}
|
|
|
|
public function getChannelLabelAttribute(): string
|
|
{
|
|
return static::$channelMeta[$this->channel]['label'] ?? ucfirst($this->channel);
|
|
}
|
|
|
|
// ── Trigger helpers ──────────────────────────────────────────
|
|
|
|
public static array $triggerMeta = [
|
|
'upcoming_event' => ['icon' => '📅', 'label' => 'Upcoming Events'],
|
|
'invoice_due' => ['icon' => '🧾', 'label' => 'Invoice Due Date'],
|
|
'content_due' => ['icon' => '🎬', 'label' => 'Content Target Date'],
|
|
];
|
|
|
|
public function hasTrigger(string $trigger): bool
|
|
{
|
|
return in_array($trigger, $this->triggers ?? []);
|
|
}
|
|
}
|