decrypt($tenantId, $value); } public function set(Model $model, string $key, mixed $value, array $attributes): ?string { if ($value === null) { return null; } $tenantId = (int) ($attributes['tenant_id'] ?? $model->getAttribute('tenant_id')); if ($tenantId < 1) { throw new RuntimeException('TENANT_CONTEXT_REQUIRED_FOR_ENCRYPTION'); } return app(TenantEnvelopeEncryption::class)->encrypt($tenantId, $value); } }