---
title: "Multi-tenant connections — Certificates for Laravel | Roundly"
description: "Keep each tenant’s registry on its own database connection — per call with on(), app-wide via config, and --connection on commands."
url: https://roundly-consulting.com/open-source/docs/certificates-for-laravel/multi-tenancy
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Certificates for Laravel](https://roundly-consulting.com/open-source/docs/certificates-for-laravel.md)

# Multi-tenant connections

Target a specific database connection per call with on(). It returns a connection-bound clone of CertificatesManager, leaving the singleton untouched, and every registry read and write through it — issue(), find(), status(), for(), renew(), renewDue(), revoke(), expire(), sync(), prune() — uses that connection:

```php
Certificates::on('tenant')->for('app.tenant.example.com')->issue();
Certificates::on('tenant')->find('app.tenant.example.com');
Certificates::on('tenant')->issueIfMissing('app.tenant.example.com');
Certificates::on('tenant')->status('app.tenant.example.com');
Certificates::on('tenant')->renewDue();
Certificates::on('tenant')->prune(30);
```

Set an app-wide default with the connection config key (CERTIFICATES\_DB\_CONNECTION). The model falls back to it whenever no connection is set explicitly; null uses the model’s default connection.

## Console

Every command accepts --connection=:

```bash
php artisan certificates:issue app.tenant.example.com --connection=tenant
php artisan certificates:list --connection=tenant
php artisan certificates:renew --connection=tenant
php artisan certificates:check --alert --connection=tenant
php artisan certificates:prune --connection=tenant
php artisan certificates:sync --driver=kubernetes --connection=tenant
```

Queued renewals keep their tenant: RenewCertificateJob carries the database connection the row was queued from (its databaseConnection property) and re-reads the row on it through the certificates.model class.

Expiry alerts keep it too: certificates:check --connection, the lifecycle alert listener and monitorExpiry() schedules check the certificate on its own connection. CertificateExpiryCheck takes a connection argument, and monitorExpiry() records the row’s connection in the schedule’s meta.

## Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

[More ways to support, including crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/certificates-for-laravel.md)
