resolveTrustModel('TrustCampaign'); if (! $class) { return null; } return $this->hasMany($class); } /** * Get all trust notifications owned by this user. */ public function trustNotifications(): ?HasMany { $class = $this->resolveTrustModel('TrustNotification'); if (! $class) { return null; } return $this->hasMany($class); } /** * Resolve a Trust model class, checking common namespaces. */ protected function resolveTrustModel(string $model): ?string { $candidates = [ "Core\\Mod\\Trust\\Models\\{$model}", "App\\Models\\{$model}", ]; foreach ($candidates as $candidate) { if (class_exists($candidate)) { return $candidate; } } return null; } }