Skip to content

Commit 3c17101

Browse files
authored
Merge branch 'spatie:main' into feat-tenant-not-found-for-request-event
2 parents 3738dd8 + 5253dce commit 3c17101

14 files changed

+32
-32
lines changed

config/multitenancy.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
'tenant_finder' => null,
2323

2424
/*
25-
* These fields are used by tenant:artisan command to match one or more tenant
25+
* These fields are used by tenant:artisan command to match one or more tenant.
2626
*/
2727
'tenant_artisan_search_fields' => [
2828
'id',
@@ -61,7 +61,7 @@
6161
'tenant_database_connection_name' => null,
6262

6363
/*
64-
* The connection name to reach the landlord database
64+
* The connection name to reach the landlord database.
6565
*/
6666
'landlord_database_connection_name' => null,
6767

@@ -88,7 +88,7 @@
8888
],
8989

9090
/*
91-
* You can customize the way in which the package resolves the queuable to a job.
91+
* You can customize the way in which the package resolves the queueable to a job.
9292
*
9393
* For example, using the package laravel-actions (by Loris Leiva), you can
9494
* resolve JobDecorator to getAction() like so: JobDecorator::class => 'getAction'

docs/advanced-usage/executing-code-for-tenants-and-landlords.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Here is an example where we flush the cache for a tenant using our landlord API:
1414
```php
1515
Route::delete('/api/{tenant}/flush-cache', function (Tenant $tenant) {
1616
$result = $tenant->execute(fn (Tenant $tenant) => cache()->flush());
17-
17+
1818
return json_encode(["success" => $result]);
1919
});
2020
```
@@ -25,12 +25,14 @@ Here's another example, where a job is dispatched from a landlord API route:
2525

2626
```php
2727
Route::post('/api/{tenant}/reminder', function (Tenant $tenant) {
28-
return json_encode([
28+
return json_encode([
2929
'data' => $tenant->execute(fn () => dispatch(ExpirationReminder())),
3030
]);
3131
});
3232
```
33+
3334
### Executing a delayed callback in the correct Tenant context
35+
3436
If you need to define a callback that will be executed in the correct Tenant context every time it is called, you can use the Tenant's `callback` method.
3537
A notable example for this is the use in the Laravel scheduler where you can loop through all the tenants and schedule callbacks to be executed at the given time:
3638

@@ -45,7 +47,7 @@ protected function schedule(Schedule $schedule)
4547

4648
## Executing landlord code in tenant request
4749

48-
To execute landlord code, from inside a tenant request, you can use the method `execute` on `Spatie\Multitenancy\Landlord`.
50+
To execute landlord code, from inside a tenant request, you can use the method `execute` on `Spatie\Multitenancy\Landlord`.
4951

5052
Here is an example where we will first clear the tenant cache, and next, the landlord cache:
5153

@@ -56,10 +58,10 @@ use Spatie\Multitenancy\Landlord;
5658

5759
Tenant::first()->execute(function (Tenant $tenant) {
5860
// it will clear the tenant cache
59-
Artisan::call('cache:clear');
60-
61+
Artisan::call('cache:clear');
62+
6163
// it will clear the landlord cache
62-
Landlord::execute(fn () => Artisan::call('cache:clear'));
64+
Landlord::execute(fn () => Artisan::call('cache:clear'));
6365
});
6466
```
6567

@@ -112,7 +114,7 @@ protected function setUp(): void
112114
Event::listen(MadeTenantCurrentEvent::class, function () {
113115
$this->beginDatabaseTransaction();
114116
});
115-
117+
116118
Tenant::first()->makeCurrent();
117119
}
118120
```

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ weight: 3
55

66
Commands can be made tenant aware by applying the `TenantAware` trait. When using the trait it is required to append `{--tenant=*}` or `{--tenant=}` to the command signature.
77

8-
Caution: If you append `{--tenant=*}`, then if no `tenant` option is provided when executing the command, the command will execute for *all* tenants.
9-
8+
Caution: If you append `{--tenant=*}`, then if no `tenant` option is provided when executing the command, the command will execute for _all_ tenants.
9+
1010
```php
1111
use Illuminate\Console\Command;
1212
use Spatie\Multitenancy\Commands\Concerns\TenantAware;
1313

14-
class YourFavouriteCommand extends Command
14+
class YourFavoriteCommand extends Command
1515
{
1616
use TenantAware;
1717

@@ -24,18 +24,16 @@ class YourFavouriteCommand extends Command
2424
}
2525
```
2626

27-
When executing the command, the `handle` method will be called for each tenant.
27+
When executing the command, the `handle` method will be called for each tenant.
2828

2929
```bash
30-
php artisan your-favorite-command
30+
php artisan your-favorite-command
3131
```
3232

3333
Using the example above, the name of each tenant will be written to the output of the command.
3434

35-
3635
You can also execute the command for a specific tenant:
3736

38-
3937
```bash
4038
php artisan your-favorite-command --tenant=1
4139
```

docs/advanced-usage/using-tenant-specific-facades.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ Facades behave like singletons. They only resolve once, and each use of the faca
77

88
If you only have a couple of tenant specific facade, we recommend only clearing them when switching a tenant. Here's a task that you could use for this.
99

10-
1110
```php
1211
namespace App\Tenancy\SwitchTasks;
1312

docs/basic-usage/making-queues-tenant-aware.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class TestJob implements ShouldQueue, TenantAware
2525
```
2626

2727
or, using the config `multitenancy.php`:
28+
2829
```php
2930
'tenant_aware_jobs' => [
3031
TestJob::class,
@@ -34,7 +35,7 @@ or, using the config `multitenancy.php`:
3435
## Making specific jobs not tenant aware
3536

3637
Jobs that never should be tenant aware should implement the empty marker interface `Spatie\Multitenancy\Jobs\NotTenantAware` or should be added to the config `not_tenant_aware_jobs`.
37-
38+
3839
```php
3940
use Illuminate\Contracts\Queue\ShouldQueue;
4041
use Spatie\Multitenancy\Jobs\NotTenantAware;
@@ -49,6 +50,7 @@ class TestJob implements ShouldQueue, NotTenantAware
4950
```
5051

5152
or, using the config `multitenancy.php`:
53+
5254
```php
5355
'not_tenant_aware_jobs' => [
5456
TestJob::class,

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ $tenant->makeCurrent();
3737

3838
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.
3939

40-
4140
### Forgetting the current tenant
4241

4342
You can forget the current tenant:

docs/installation/base-installation.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ return [
4444
'tenant_finder' => null,
4545

4646
/*
47-
* These fields are used by tenant:artisan command to match one or more tenant
47+
* These fields are used by tenant:artisan command to match one or more tenant.
4848
*/
4949
'tenant_artisan_search_fields' => [
5050
'id',
@@ -83,7 +83,7 @@ return [
8383
'tenant_database_connection_name' => null,
8484

8585
/*
86-
* The connection name to reach the landlord database
86+
* The connection name to reach the landlord database.
8787
*/
8888
'landlord_database_connection_name' => null,
8989

@@ -110,7 +110,7 @@ return [
110110
],
111111

112112
/*
113-
* You can customize the way in which the package resolves the queuable to a job.
113+
* You can customize the way in which the package resolves the queueable to a job.
114114
*
115115
* For example, using the package laravel-actions (by Loris Leiva), you can
116116
* resolve JobDecorator to getAction() like so: JobDecorator::class => 'getAction'

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ weight: 2
55

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

8-
Only use the instructions on this page if you want to use one database.
8+
Only use the instructions on this page if you want to use one database.
99

1010
### Migrating the database
1111

docs/installation/using-multiple-databases.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ In the example below, the `mysql` driver is used, but you can use any driver you
4040
],
4141
```
4242

43-
4443
### Migrating the landlord database
4544

4645
With the database connection set up, we can migrate the landlord database.
@@ -101,7 +100,7 @@ php artisan tenants:artisan "migrate --database=tenant"
101100
If you want to have dedicated directory for tenant migrations (`database/migrations/tenant`) you can simply run:
102101

103102
```bash
104-
php artisan tenants:artisan "migrate --path=database/migrations/tenant --database=tenant"
103+
php artisan tenants:artisan "migrate --path=database/migrations/tenant --database=tenant"
105104
```
106105

107106
### Seeding tenant databases

docs/requirements.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ title: Requirements
33
weight: 3
44
---
55

6-
This package requires **PHP 8.0+** and **Laravel 8.0+**.
6+
This package requires **PHP 8.0+** and **Laravel 8.0+**.

docs/support-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ title: Support us
33
weight: 2
44
---
55

6-
We invest a lot of resources into creating our [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).
6+
We invest a lot of resources into creating our [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).
77

88
We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

docs/using-tasks-to-prepare-the-environment/creating-your-own-task.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ use Spatie\Multitenancy\Tasks\SwitchTenantTask;
8282
class SwitchTenantDatabaseTask implements SwitchTenantTask
8383
{
8484
public function __construct(string $name, string $anotherName)
85-
{
85+
{
8686
// do something
8787
}
8888
}
@@ -98,7 +98,7 @@ use Spatie\Multitenancy\Tasks\SwitchTenantTask;
9898
class SwitchTenantDatabaseTask implements SwitchTenantTask
9999
{
100100
public function __construct(string $name, string $anotherName, MyDepencency $myDependency)
101-
{
101+
{
102102
// do something
103103
}
104104
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ You can easily [create your own tasks](/docs/laravel-multitenancy/v3/using-tasks
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/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)
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/switching-route-cache-paths.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ In the default scenario, all tenants have different routes. The package creates
3232
It's the scenario where all tenants use the same routes. The package creates a shared route cache file for all tenants: `bootstrap/cache/routes-v7-tenants.php`.
3333

3434
To enable the feature you should set to `true` the `shared_routes_cache` section of the `multitenancy` config file.
35+
3536
```php
3637
// in config/multitenancy.php
3738

0 commit comments

Comments
 (0)