events as $event) { nlog($event['action']); $e = Arr::dot($event); if ($event['action'] === 'disconnected') { /** @var \App\Models\CompanyGateway $company_gateway */ $company_gateway = CompanyGateway::query() ->whereJsonContains('config->account_id', $e['links.organisation']) ->firstOrFail(); $current = $company_gateway->getConfig('__current'); if ($current) { $company_gateway->setConfig($current); $company_gateway->save(); } $this->company_repository->archive($company_gateway); } } } }