From a9d125c67aea0695d34956f3d3a63e8fb605b5fe Mon Sep 17 00:00:00 2001 From: Freek Van der Herten Date: Wed, 24 Jul 2024 13:35:32 +0200 Subject: [PATCH] prep for v4 --- docs/_index.md | 2 +- docs/advanced-usage/listening-for-events.md | 8 ++++---- .../making-artisan-commands-tenant-aware.md | 2 +- .../automatically-determining-the-current-tenant.md | 2 +- docs/basic-usage/working-with-the-current-tenant.md | 2 +- docs/installation/base-installation.md | 6 +++--- docs/installation/determining-current-tenant.md | 2 +- docs/installation/using-a-single-database.md | 6 +++--- docs/installation/using-multiple-databases.md | 10 +++++----- .../using-tasks-to-prepare-the-environment/overview.md | 6 +++--- .../prefixing-cache.md | 2 +- .../switching-databases.md | 2 +- 12 files changed, 25 insertions(+), 25 deletions(-) diff --git a/docs/_index.md b/docs/_index.md index ef68895d..46be6e6a 100644 --- a/docs/_index.md +++ b/docs/_index.md @@ -1,5 +1,5 @@ --- -title: v3 +title: v4 slogan: An unopinionated multitenancy package for Laravel apps githubUrl: https://github.com/spatie/laravel-multitenancy branch: main diff --git a/docs/advanced-usage/listening-for-events.md b/docs/advanced-usage/listening-for-events.md index ca58fe33..4c88da46 100644 --- a/docs/advanced-usage/listening-for-events.md +++ b/docs/advanced-usage/listening-for-events.md @@ -7,25 +7,25 @@ The package fires events where you can listen for to perform some extra logic. ## `\Spatie\Multitenancy\Events\MakingTenantCurrentEvent` -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. +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. It has one public property `$tenant`, that contains an instance of `Spatie\Multitenancy\Models\Tenant`. ## `\Spatie\Multitenancy\Events\MadeTenantCurrentEvent` -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. +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. It has one public property `$tenant`, that contains an instance of `Spatie\Multitenancy\Models\Tenant`. ## `\Spatie\Multitenancy\Events\ForgettingCurrentTenantEvent` -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. +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. It has one public property `$tenant`, that contains an instance of `Spatie\Multitenancy\Models\Tenant`. ## `\Spatie\Multitenancy\Events\ForgotCurrentTenantEvent` -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. +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. ## `\Spatie\Multitenancy\Events\TenantNotFoundForRequestEvent` diff --git a/docs/advanced-usage/making-artisan-commands-tenant-aware.md b/docs/advanced-usage/making-artisan-commands-tenant-aware.md index a8659c67..49fa070e 100644 --- a/docs/advanced-usage/making-artisan-commands-tenant-aware.md +++ b/docs/advanced-usage/making-artisan-commands-tenant-aware.md @@ -42,7 +42,7 @@ php artisan your-favorite-command --tenant=1 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 `. This command will loop over tenants and for each of them make that tenant current, and execute the artisan command. -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)): +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)): ```bash php artisan tenants:artisan migrate diff --git a/docs/basic-usage/automatically-determining-the-current-tenant.md b/docs/basic-usage/automatically-determining-the-current-tenant.md index 6e490b00..b6d0fe4d 100644 --- a/docs/basic-usage/automatically-determining-the-current-tenant.md +++ b/docs/basic-usage/automatically-determining-the-current-tenant.md @@ -19,7 +19,7 @@ In the `multitenancy` config file, you specify the tenant finder in the `tenant_ 'tenant_finder' => Spatie\Multitenancy\TenantFinder\DomainTenantFinder::class, ``` -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. +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. ```php app('currentTenant') // will return the current tenant or `null` diff --git a/docs/basic-usage/working-with-the-current-tenant.md b/docs/basic-usage/working-with-the-current-tenant.md index db0a2eff..403c452e 100644 --- a/docs/basic-usage/working-with-the-current-tenant.md +++ b/docs/basic-usage/working-with-the-current-tenant.md @@ -43,7 +43,7 @@ You can manually make a tenant the current one by calling `makeCurrent()` on it. $tenant->makeCurrent(); ``` -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. +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. ### Forgetting the current tenant diff --git a/docs/installation/base-installation.md b/docs/installation/base-installation.md index e0b282ce..27a26352 100644 --- a/docs/installation/base-installation.md +++ b/docs/installation/base-installation.md @@ -173,10 +173,10 @@ Route::middleware('tenant')->group(function() { }); ``` -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). +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). ### Next steps -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). +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). -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). +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). diff --git a/docs/installation/determining-current-tenant.md b/docs/installation/determining-current-tenant.md index e5e4e4b1..78586f59 100644 --- a/docs/installation/determining-current-tenant.md +++ b/docs/installation/determining-current-tenant.md @@ -19,4 +19,4 @@ To use that tenant finder, specify its class name in the `tenant_finder` key of 'tenant_finder' => Spatie\Multitenancy\TenantFinder\DomainTenantFinder::class, ``` -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/). +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/). diff --git a/docs/installation/using-a-single-database.md b/docs/installation/using-a-single-database.md index aeee4f7b..6efe8003 100644 --- a/docs/installation/using-a-single-database.md +++ b/docs/installation/using-a-single-database.md @@ -3,7 +3,7 @@ title: Using a single database weight: 2 --- -Before using the following instructions, make sure you have performed [the base installation steps](/docs/laravel-multitenancy/v3/installation/base-installation) first. +Before using the following instructions, make sure you have performed [the base installation steps](/docs/laravel-multitenancy/v4/installation/base-installation) first. Only use the instructions on this page if you want to use one database. @@ -22,6 +22,6 @@ This will create the `tenants` table which holds configuration per tenant. ### Next steps -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. +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. -The package also has an option to [make the queue tenant aware](/docs/laravel-multitenancy/v3/basic-usage/making-queues-tenant-aware/). +The package also has an option to [make the queue tenant aware](/docs/laravel-multitenancy/v4/basic-usage/making-queues-tenant-aware/). diff --git a/docs/installation/using-multiple-databases.md b/docs/installation/using-multiple-databases.md index 5fe3b1c6..6926ff88 100644 --- a/docs/installation/using-multiple-databases.md +++ b/docs/installation/using-multiple-databases.md @@ -3,7 +3,7 @@ title: Using multiple databases weight: 3 --- -Before using the following instructions, make sure you have performed [the base installation steps](/docs/laravel-multitenancy/v3/installation/base-installation) first. +Before using the following instructions, make sure you have performed [the base installation steps](/docs/laravel-multitenancy/v4/installation/base-installation) first. Only use the instructions on this page if you want each of your tenants to have their own database. @@ -79,11 +79,11 @@ You should add this task to the `switch_tenant_tasks` key. ], ``` -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/). +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/). ### Creating tenant databases -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). +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). 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. @@ -91,7 +91,7 @@ If you want to get a feel of how the package works, you could create a couple of When you want to migrate tenant databases, all future migrations should be stored in `database/migrations`. -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. +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. ```bash php artisan tenants:artisan "migrate --database=tenant" @@ -144,4 +144,4 @@ All models in your project should either use the `UsesLandlordConnection` or `Us ### Next steps -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. +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. diff --git a/docs/using-tasks-to-prepare-the-environment/overview.md b/docs/using-tasks-to-prepare-the-environment/overview.md index d30e84b5..ca36211f 100644 --- a/docs/using-tasks-to-prepare-the-environment/overview.md +++ b/docs/using-tasks-to-prepare-the-environment/overview.md @@ -7,11 +7,11 @@ When making a tenant the current one, the tasks inside the `switch_tenant_tasks` 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. -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. +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. The package ships with these tasks: -- [switch the tenant database](/docs/laravel-multitenancy/v3/using-tasks-to-prepare-the-environment/switching-databases) (required when using multiple tenant databases) -- [prefixing the cache](/docs/laravel-multitenancy/v3/using-tasks-to-prepare-the-environment/prefixing-cache) +- [switch the tenant database](/docs/laravel-multitenancy/v4/using-tasks-to-prepare-the-environment/switching-databases) (required when using multiple tenant databases) +- [prefixing the cache](/docs/laravel-multitenancy/v4/using-tasks-to-prepare-the-environment/prefixing-cache) These tasks are optional. When you need one, just add it to the `switch_tenant_tasks` key of the `multitenancy` config file. diff --git a/docs/using-tasks-to-prepare-the-environment/prefixing-cache.md b/docs/using-tasks-to-prepare-the-environment/prefixing-cache.md index 00a0c559..f5d137ab 100644 --- a/docs/using-tasks-to-prepare-the-environment/prefixing-cache.md +++ b/docs/using-tasks-to-prepare-the-environment/prefixing-cache.md @@ -41,4 +41,4 @@ cache('key') // returns 'value-for-another-tenant' Behind the scenes, this works by dynamically changing the `cache.prefix` in the `cache` config file whenever another tenant is made current. -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. +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. diff --git a/docs/using-tasks-to-prepare-the-environment/switching-databases.md b/docs/using-tasks-to-prepare-the-environment/switching-databases.md index 97036b95..68386a2f 100644 --- a/docs/using-tasks-to-prepare-the-environment/switching-databases.md +++ b/docs/using-tasks-to-prepare-the-environment/switching-databases.md @@ -16,4 +16,4 @@ To use this task, you should add it to the `switch_tenant_tasks` key in the `mul ], ``` -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. +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.