platform; if (! $platform instanceof Platform) { return; } $conflict = SocialAccount::query() ->where('workspace_id', $socialAccount->workspace_id) ->whereIn('platform', $platform->networkPlatformValues()) ->exists(); if ($conflict) { throw new NetworkAlreadyConnectedException($platform); } } public function created(SocialAccount $socialAccount): void { $this->syncUsage($socialAccount); } public function deleted(SocialAccount $socialAccount): void { $this->syncUsage($socialAccount); } private function syncUsage(SocialAccount $socialAccount): void { if (! PostHogService::isEnabled()) { return; } SyncAccountUsage::dispatch( (string) $socialAccount->workspace->account_id, (string) $socialAccount->workspace_id, ); } }