Skip to content

Commit a9d125c

Browse files
committed
prep for v4
1 parent 8a22870 commit a9d125c

12 files changed

+25
-25
lines changed

docs/_index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: v3
2+
title: v4
33
slogan: An unopinionated multitenancy package for Laravel apps
44
githubUrl: https://github.com/spatie/laravel-multitenancy
55
branch: main

docs/advanced-usage/listening-for-events.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,25 @@ The package fires events where you can listen for to perform some extra logic.
77

88
## `\Spatie\Multitenancy\Events\MakingTenantCurrentEvent`
99

10-
This event will fire when a tenant is being made the current one. At this point none of [the tasks](/docs/laravel-multitenancy/v3/using-tasks-to-prepare-the-environment/overview/) have been executed.
10+
This event will fire when a tenant is being made the current one. At this point none of [the tasks](/docs/laravel-multitenancy/v4/using-tasks-to-prepare-the-environment/overview/) have been executed.
1111

1212
It has one public property `$tenant`, that contains an instance of `Spatie\Multitenancy\Models\Tenant`.
1313

1414
## `\Spatie\Multitenancy\Events\MadeTenantCurrentEvent`
1515

16-
This event will fire when a tenant has been made the current one. At this point the `makeCurrent` method of all of [the tasks](/docs/laravel-multitenancy/v3/using-tasks-to-prepare-the-environment/overview/) have been executed. The current tenant also have been bound as `currentTenant` in the container.
16+
This event will fire when a tenant has been made the current one. At this point the `makeCurrent` method of all of [the tasks](/docs/laravel-multitenancy/v4/using-tasks-to-prepare-the-environment/overview/) have been executed. The current tenant also have been bound as `currentTenant` in the container.
1717

1818
It has one public property `$tenant`, that contains an instance of `Spatie\Multitenancy\Models\Tenant`.
1919

2020
## `\Spatie\Multitenancy\Events\ForgettingCurrentTenantEvent`
2121

22-
This event will fire when a tenant is being forgotten. At this point none of [the tasks](/docs/laravel-multitenancy/v3/using-tasks-to-prepare-the-environment/overview/) have been executed.
22+
This event will fire when a tenant is being forgotten. At this point none of [the tasks](/docs/laravel-multitenancy/v4/using-tasks-to-prepare-the-environment/overview/) have been executed.
2323

2424
It has one public property `$tenant`, that contains an instance of `Spatie\Multitenancy\Models\Tenant`.
2525

2626
## `\Spatie\Multitenancy\Events\ForgotCurrentTenantEvent`
2727

28-
This event will fire when a tenant has been forgotten. At this point the `forgotCurrent` method of all of [the tasks](/docs/laravel-multitenancy/v3/using-tasks-to-prepare-the-environment/overview/) have been executed. `currentTenant` in the container has been emptied.
28+
This event will fire when a tenant has been forgotten. At this point the `forgotCurrent` method of all of [the tasks](/docs/laravel-multitenancy/v4/using-tasks-to-prepare-the-environment/overview/) have been executed. `currentTenant` in the container has been emptied.
2929

3030
## `\Spatie\Multitenancy\Events\TenantNotFoundForRequestEvent`
3131

docs/advanced-usage/making-artisan-commands-tenant-aware.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ php artisan your-favorite-command --tenant=1
4242

4343
If you cannot change an Artisan command yourself, for instance a command from Laravel itself or a command from a package, you can use `tenants:artisan <artisan command>`. This command will loop over tenants and for each of them make that tenant current, and execute the artisan command.
4444

45-
When your tenants each have their own database, you could migrate each tenant database with this command (given you are using a task like [`SwitchTenantDatabase`](https://docs.spatie.be/laravel-multitenancy/v3/using-tasks-to-prepare-the-environment/switching-databases)):
45+
When your tenants each have their own database, you could migrate each tenant database with this command (given you are using a task like [`SwitchTenantDatabase`](https://docs.spatie.be/laravel-multitenancy/v4/using-tasks-to-prepare-the-environment/switching-databases)):
4646

4747
```bash
4848
php artisan tenants:artisan migrate

docs/basic-usage/automatically-determining-the-current-tenant.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ In the `multitenancy` config file, you specify the tenant finder in the `tenant_
1919
'tenant_finder' => Spatie\Multitenancy\TenantFinder\DomainTenantFinder::class,
2020
```
2121

22-
If there is a tenant returned by the tenant finder, [all configured tasks](https://docs.spatie.be/laravel-multitenancy/v3/using-tasks-to-prepare-the-environment/overview/) will be performed on it. After that, the tenant instance will be bound in the container using the `currentTenant` key.
22+
If there is a tenant returned by the tenant finder, [all configured tasks](https://docs.spatie.be/laravel-multitenancy/v4/using-tasks-to-prepare-the-environment/overview/) will be performed on it. After that, the tenant instance will be bound in the container using the `currentTenant` key.
2323

2424
```php
2525
app('currentTenant') // will return the current tenant or `null`

docs/basic-usage/working-with-the-current-tenant.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ You can manually make a tenant the current one by calling `makeCurrent()` on it.
4343
$tenant->makeCurrent();
4444
```
4545

46-
When a tenant is made the current one, the package will run the `makeCurrent` method of [all tasks configured](/docs/laravel-multitenancy/v3/using-tasks-to-prepare-the-environment/overview/) in the `switch_tenant_tasks` key of the `multitenancy` config file.
46+
When a tenant is made the current one, the package will run the `makeCurrent` method of [all tasks configured](/docs/laravel-multitenancy/v4/using-tasks-to-prepare-the-environment/overview/) in the `switch_tenant_tasks` key of the `multitenancy` config file.
4747

4848
### Forgetting the current tenant
4949

docs/installation/base-installation.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,10 @@ Route::middleware('tenant')->group(function() {
173173
});
174174
```
175175

176-
This middleware will respond with an unauthorized response code (401) when the user tries to use their session to view another tenant. Make sure to include `\Spatie\Multitenancy\Http\Middleware\NeedsTenant` first, as this will [handle any cases where a valid tenant cannot be found](/docs/laravel-multitenancy/v3/advanced-usage/ensuring-a-current-tenant-has-been-set).
176+
This middleware will respond with an unauthorized response code (401) when the user tries to use their session to view another tenant. Make sure to include `\Spatie\Multitenancy\Http\Middleware\NeedsTenant` first, as this will [handle any cases where a valid tenant cannot be found](/docs/laravel-multitenancy/v4/advanced-usage/ensuring-a-current-tenant-has-been-set).
177177

178178
### Next steps
179179

180-
If you prefer to use just one glorious database for all your tenants, read the installation instructions for [using a single database](/docs/laravel-multitenancy/v3/installation/using-a-single-database).
180+
If you prefer to use just one glorious database for all your tenants, read the installation instructions for [using a single database](/docs/laravel-multitenancy/v4/installation/using-a-single-database).
181181

182-
If you want to use separate databases for each tenant, head over to the installation instructions for [using multiple databases](/docs/laravel-multitenancy/v3/installation/using-multiple-databases).
182+
If you want to use separate databases for each tenant, head over to the installation instructions for [using multiple databases](/docs/laravel-multitenancy/v4/installation/using-multiple-databases).

docs/installation/determining-current-tenant.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ To use that tenant finder, specify its class name in the `tenant_finder` key of
1919
'tenant_finder' => Spatie\Multitenancy\TenantFinder\DomainTenantFinder::class,
2020
```
2121

22-
If you want to determine the "current" tenant some other way, you can [create a custom tenant finder](/docs/laravel-multitenancy/v3/basic-usage/automatically-determining-the-current-tenant/).
22+
If you want to determine the "current" tenant some other way, you can [create a custom tenant finder](/docs/laravel-multitenancy/v4/basic-usage/automatically-determining-the-current-tenant/).

docs/installation/using-a-single-database.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Using a single database
33
weight: 2
44
---
55

6-
Before using the following instructions, make sure you have performed [the base installation steps](/docs/laravel-multitenancy/v3/installation/base-installation) first.
6+
Before using the following instructions, make sure you have performed [the base installation steps](/docs/laravel-multitenancy/v4/installation/base-installation) first.
77

88
Only use the instructions on this page if you want to use one database.
99

@@ -22,6 +22,6 @@ This will create the `tenants` table which holds configuration per tenant.
2222

2323
### Next steps
2424

25-
When using multiple tenants, you probably want to [isolate the cache](/docs/laravel-multitenancy/v3/using-tasks-to-prepare-the-environment/prefixing-cache/) or use your own separated filesystems per tenant, ... These things are performed by [task classes](/docs/laravel-multitenancy/v3/using-tasks-to-prepare-the-environment/overview/) that will be executed when making a tenant the current one.
25+
When using multiple tenants, you probably want to [isolate the cache](/docs/laravel-multitenancy/v4/using-tasks-to-prepare-the-environment/prefixing-cache/) or use your own separated filesystems per tenant, ... These things are performed by [task classes](/docs/laravel-multitenancy/v4/using-tasks-to-prepare-the-environment/overview/) that will be executed when making a tenant the current one.
2626

27-
The package also has an option to [make the queue tenant aware](/docs/laravel-multitenancy/v3/basic-usage/making-queues-tenant-aware/).
27+
The package also has an option to [make the queue tenant aware](/docs/laravel-multitenancy/v4/basic-usage/making-queues-tenant-aware/).

docs/installation/using-multiple-databases.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Using multiple databases
33
weight: 3
44
---
55

6-
Before using the following instructions, make sure you have performed [the base installation steps](/docs/laravel-multitenancy/v3/installation/base-installation) first.
6+
Before using the following instructions, make sure you have performed [the base installation steps](/docs/laravel-multitenancy/v4/installation/base-installation) first.
77

88
Only use the instructions on this page if you want each of your tenants to have their own database.
99

@@ -79,19 +79,19 @@ You should add this task to the `switch_tenant_tasks` key.
7979
],
8080
```
8181

82-
The package also provides [other tasks](/docs/laravel-multitenancy/v3/using-tasks-to-prepare-the-environment/overview/) that you could optionally add to `switch_tenant_tasks`. You can also [create a custom task](/docs/laravel-multitenancy/v3/using-tasks-to-prepare-the-environment/creating-your-own-task/).
82+
The package also provides [other tasks](/docs/laravel-multitenancy/v4/using-tasks-to-prepare-the-environment/overview/) that you could optionally add to `switch_tenant_tasks`. You can also [create a custom task](/docs/laravel-multitenancy/v4/using-tasks-to-prepare-the-environment/creating-your-own-task/).
8383

8484
### Creating tenant databases
8585

86-
Now that automatic database switching for tenants is configured, you can migrate the tenant databases. Because there are so many ways to go about it, the package does not handle creating databases. You should take care of creating new tenant databases in your own application code. A nice place to trigger this could be [when a `Tenant` model gets created](/docs/laravel-multitenancy/v3/advanced-usage/using-a-custom-tenant-model/#performing-actions-when-a-tenant-gets-created).
86+
Now that automatic database switching for tenants is configured, you can migrate the tenant databases. Because there are so many ways to go about it, the package does not handle creating databases. You should take care of creating new tenant databases in your own application code. A nice place to trigger this could be [when a `Tenant` model gets created](/docs/laravel-multitenancy/v4/advanced-usage/using-a-custom-tenant-model/#performing-actions-when-a-tenant-gets-created).
8787

8888
If you want to get a feel of how the package works, you could create a couple of rows in the `tenants` table, fill the `database` attribute and manually create those databases.
8989

9090
### Migrating tenant databases
9191

9292
When you want to migrate tenant databases, all future migrations should be stored in `database/migrations`.
9393

94-
To perform these migrations, you can use [the `tenants:migrate` command](/docs/laravel-multitenancy/v3/advanced-usage/executing-artisan-commands-for-each-tenant). This command will loop over all rows in the `tenants` table. It will make each tenant the current one, and migrate the database.
94+
To perform these migrations, you can use [the `tenants:migrate` command](/docs/laravel-multitenancy/v4/advanced-usage/executing-artisan-commands-for-each-tenant). This command will loop over all rows in the `tenants` table. It will make each tenant the current one, and migrate the database.
9595

9696
```bash
9797
php artisan tenants:artisan "migrate --database=tenant"
@@ -144,4 +144,4 @@ All models in your project should either use the `UsesLandlordConnection` or `Us
144144

145145
### Next steps
146146

147-
When using multiple tenants, you probably want to [isolate the cache](/docs/laravel-multitenancy/v3/using-tasks-to-prepare-the-environment/prefixing-cache/). This is performed by task classes that will be executed when making a tenant the current one.
147+
When using multiple tenants, you probably want to [isolate the cache](/docs/laravel-multitenancy/v4/using-tasks-to-prepare-the-environment/prefixing-cache/). This is performed by task classes that will be executed when making a tenant the current one.

docs/using-tasks-to-prepare-the-environment/overview.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ When making a tenant the current one, the tasks inside the `switch_tenant_tasks`
77

88
The philosophy of this package is that it should only provide the bare essentials to enable multitenancy. That's why it only provides two tasks out of the box. These tasks serve as example implementations.
99

10-
You can easily [create your own tasks](/docs/laravel-multitenancy/v3/using-tasks-to-prepare-the-environment/creating-your-own-task/) that fit your particular project.
10+
You can easily [create your own tasks](/docs/laravel-multitenancy/v4/using-tasks-to-prepare-the-environment/creating-your-own-task/) that fit your particular project.
1111

1212
The package ships with these tasks:
1313

14-
- [switch the tenant database](/docs/laravel-multitenancy/v3/using-tasks-to-prepare-the-environment/switching-databases) (required when using multiple tenant databases)
15-
- [prefixing the cache](/docs/laravel-multitenancy/v3/using-tasks-to-prepare-the-environment/prefixing-cache)
14+
- [switch the tenant database](/docs/laravel-multitenancy/v4/using-tasks-to-prepare-the-environment/switching-databases) (required when using multiple tenant databases)
15+
- [prefixing the cache](/docs/laravel-multitenancy/v4/using-tasks-to-prepare-the-environment/prefixing-cache)
1616

1717
These tasks are optional. When you need one, just add it to the `switch_tenant_tasks` key of the `multitenancy` config file.

docs/using-tasks-to-prepare-the-environment/prefixing-cache.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ cache('key') // returns 'value-for-another-tenant'
4141

4242
Behind the scenes, this works by dynamically changing the `cache.prefix` in the `cache` config file whenever another tenant is made current.
4343

44-
If you want to make the cache tenant aware in another way, you should [create your own task](/docs/laravel-multitenancy/v3/using-tasks-to-prepare-the-environment/creating-your-own-task/). You can take a look at the source code of `PrefixCacheTask` for inspiration.
44+
If you want to make the cache tenant aware in another way, you should [create your own task](/docs/laravel-multitenancy/v4/using-tasks-to-prepare-the-environment/creating-your-own-task/). You can take a look at the source code of `PrefixCacheTask` for inspiration.

docs/using-tasks-to-prepare-the-environment/switching-databases.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ To use this task, you should add it to the `switch_tenant_tasks` key in the `mul
1616
],
1717
```
1818

19-
If you want to change other database connection properties beside the database name, you should [create your own task](/docs/laravel-multitenancy/v3/using-tasks-to-prepare-the-environment/creating-your-own-task/). You can take a look at the source code of `SwitchTenantDatabaseTask` for inspiration.
19+
If you want to change other database connection properties beside the database name, you should [create your own task](/docs/laravel-multitenancy/v4/using-tasks-to-prepare-the-environment/creating-your-own-task/). You can take a look at the source code of `SwitchTenantDatabaseTask` for inspiration.

0 commit comments

Comments
 (0)