*/ use HasFactory, Notifiable, HasApiTokens; /** * The attributes that are mass assignable. * * @var list */ protected $fillable = [ 'name', 'email', 'password', 'notification_preferences', 'notification_channels', 'slack_webhook_url', 'telegram_chat_id', 'discord_webhook_url', 'teams_webhook_url', 'google_chat_webhook_url', 'webhook_url', 'sms_phone_number', 'opsgenie_api_key', 'pagerduty_integration_key', ]; /** * The attributes that should be hidden for serialization. * * @var list */ protected $hidden = [ 'password', 'remember_token', ]; /** * Get the attributes that should be cast. * * @return array */ protected function casts(): array { return [ 'email_verified_at' => 'datetime', 'password' => 'hashed', 'notification_preferences' => 'array', 'notification_channels' => 'array', ]; } /** * Get enabled notification channels for a specific alert type */ public function getNotificationChannelsFor(string $alertType): array { $channels = $this->notification_channels ?? []; return $channels[$alertType] ?? ['database']; } /** * Route notification for Slack */ public function routeNotificationForSlack(): ?string { return $this->slack_webhook_url; } /** * Route notification for Telegram */ public function routeNotificationForTelegram(): ?string { return $this->telegram_chat_id; } /** * Route notification for Discord */ public function routeNotificationForDiscord(): ?string { return $this->discord_webhook_url; } public function sites(): HasMany { return $this->hasMany(Site::class); } public function notifications(): HasMany { return $this->hasMany(Notification::class); } }