connection->transaction(function () use ($data, $server) { $oldOwner = $server->user; $server->forceFill([ 'external_id' => Arr::get($data, 'external_id'), 'owner_id' => Arr::get($data, 'owner_id'), 'name' => Arr::get($data, 'name'), 'description' => Arr::get($data, 'description') ?? '', ])->saveOrFail(); // If the owner_id value is changed we need to revoke any tokens that exist for the server // on the daemon instance so that the old owner no longer has any permission to access the // websockets. if ($server->owner_id !== $oldOwner->id) { RevokeSftpAccessJob::dispatch($oldOwner->uuid, $server); } return $server; }); } }