'brain_recall'])` * * @return array */ public function dispatch(int $workspaceId, string $eventType, array $data): array { $endpoints = WebhookEndpoint::query() ->forWorkspace($workspaceId) ->active() ->forEvent($eventType) ->get(); if ($endpoints->isEmpty()) { return []; } $deliveries = []; DB::transaction(function () use ($data, $endpoints, $eventType, $workspaceId, &$deliveries): void { foreach ($endpoints as $endpoint) { $delivery = WebhookDelivery::createForEvent($endpoint, $eventType, $data, $workspaceId); $deliveries[] = $delivery; DeliverWebhookJob::dispatch($delivery)->afterCommit(); } }); return $deliveries; } }