mirror of
https://github.com/stancl/tenancy-docs.git
synced 2025-12-12 18:24:03 +00:00
commit
2f105d2e28
3 changed files with 11 additions and 7 deletions
|
|
@ -24,7 +24,7 @@ Available storage drivers:
|
||||||
- `data_column` - the name of column that holds the tenant's data in a single JSON string
|
- `data_column` - the name of column that holds the tenant's data in a single JSON string
|
||||||
- `custom_columns` - list of keys that shouldn't be put into the data column, but into their own column
|
- `custom_columns` - list of keys that shouldn't be put into the data column, but into their own column
|
||||||
- `connection` - what database connection should be used to store tenant data (`null` means the default connection)
|
- `connection` - what database connection should be used to store tenant data (`null` means the default connection)
|
||||||
- `table_names` - the table names used by each the models that come with the storage driver
|
- `table_names` - the table names used by the models that come with the storage driver
|
||||||
|
|
||||||
> Note: Don't use the models directly. You're supposed to use [storage]({{ $page->link('tenant-storage') }}) methods on `Tenant` objects.
|
> Note: Don't use the models directly. You're supposed to use [storage]({{ $page->link('tenant-storage') }}) methods on `Tenant` objects.
|
||||||
|
|
||||||
|
|
@ -50,7 +50,7 @@ You can set the suffix to `.sqlite` if you're using sqlite and want the files to
|
||||||
|
|
||||||
If `tenancy.redis.tenancy` is set to true, connections listed in `tenancy.redis.prefixed_connections` will be prefixed with `config('tenancy.redis.prefix_base') . $id`.
|
If `tenancy.redis.tenancy` is set to true, connections listed in `tenancy.redis.prefixed_connections` will be prefixed with `config('tenancy.redis.prefix_base') . $id`.
|
||||||
|
|
||||||
> Note: You need phpredis. Predis support will dropped by Laravel on version 7.
|
> Note: You need phpredis. Predis support will dropped by Laravel in version 7.
|
||||||
|
|
||||||
### `cache` {#cache}
|
### `cache` {#cache}
|
||||||
|
|
||||||
|
|
@ -94,7 +94,7 @@ The aliases are used by the [event system]({{ $page->link('event-system') }})
|
||||||
|
|
||||||
### `features` {#bootstrappers}
|
### `features` {#bootstrappers}
|
||||||
|
|
||||||
Features are similar to bootstrappers, but they are executed regardless of whether tenancy has been initialized or not. Their purpose is to provide additional functionality that is not necessary for the package to work. Things like easy redirects to tenant domains, tags in Telescope, etc.
|
Features are similar to bootstrappers, but they are executed regardless of whether tenancy has been initialized or not. Their purpose is to provide additional functionality beyond what is necessary for the package to work. Things like easy redirects to tenant domains, tags in Telescope, etc.
|
||||||
|
|
||||||
### `home_url` {#home-url}
|
### `home_url` {#home-url}
|
||||||
|
|
||||||
|
|
@ -103,11 +103,13 @@ When a user tries to visit a non-tenant route on a tenant domain, the `PreventAc
|
||||||
### `migrate_after_creation` {#migrate-after-creation}
|
### `migrate_after_creation` {#migrate-after-creation}
|
||||||
|
|
||||||
Run migrations after creating a tenant.
|
Run migrations after creating a tenant.
|
||||||
|
|
||||||
- Default: `false`
|
- Default: `false`
|
||||||
|
|
||||||
### `delete_database_after_tenant_deletion` {#delete-database-after-tenant-deletion}
|
### `delete_database_after_tenant_deletion` {#delete-database-after-tenant-deletion}
|
||||||
|
|
||||||
Delete the tenant's database after deleting the tenant.
|
Delete the tenant's database after deleting the tenant.
|
||||||
|
|
||||||
- Default: `false`
|
- Default: `false`
|
||||||
|
|
||||||
### `queue_database_creation` {#queue-database-creation}
|
### `queue_database_creation` {#queue-database-creation}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ A frequently asked question is the difference between this package and [tenancy/
|
||||||
|
|
||||||
Packages like tenancy/multi-tenant and tenancy/tenancy give you an API for making your application multi-tenant. They give you a tenant DB connection, traits to apply on your models, a guide on creating your own tenant-aware cache, etc.
|
Packages like tenancy/multi-tenant and tenancy/tenancy give you an API for making your application multi-tenant. They give you a tenant DB connection, traits to apply on your models, a guide on creating your own tenant-aware cache, etc.
|
||||||
|
|
||||||
This package (stancl/tenancy) makes your application multi-tenant automatically and attempts to make you not have to change any things in your code. The philosophy behind this approach is that you should write your app, not tenancy boilerplate.
|
This package (stancl/tenancy) makes your application multi-tenant automatically and attempts to make you not have to change anything in your code. The philosophy behind this approach is that you should write your app, not tenancy boilerplate.
|
||||||
|
|
||||||
Apart from saving you a ton of time, the benefit of going with the automatic approach (stancl/tenancy) is that you can adapt easily, since you're not bound to a specific implementation of multi-tenancy. [You can always change how tenancy is bootstrapped.]({{ $page->link('tenancy-bootstrappers') }})
|
Apart from saving you a ton of time, the benefit of going with the automatic approach (stancl/tenancy) is that you can adapt easily, since you're not bound to a specific implementation of multi-tenancy. [You can always change how tenancy is bootstrapped.]({{ $page->link('tenancy-bootstrappers') }})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,14 +17,14 @@ The database storage driver lets you store tenant information in a relational da
|
||||||
|
|
||||||
The benefit of this storage driver is that you don't have to use both Redis and a database for your data. Also you don't have to do as much configuration.
|
The benefit of this storage driver is that you don't have to use both Redis and a database for your data. Also you don't have to do as much configuration.
|
||||||
|
|
||||||
To use this driver, you need to have a `tenants` table and a `domains` table. You may also use a custom database connection. By default, `tenancy.storage.db.connection` is set to `null`, which means that the your default database connection will be used to store tenants. If you wish to use a different connection, you may create a it in the `config/database.php` file and set `tenancy.storage.db.connection` to the name of that connection.
|
To use this driver, you need to have a `tenants` table and a `domains` table. You may also use a custom database connection. By default, `tenancy.storage.db.connection` is set to `null`, which means that your app's default database connection will be used to store tenants. If you wish to use a different connection, you may create it in the `config/database.php` file and set `tenancy.storage.db.connection` to the name of that connection.
|
||||||
|
|
||||||
To create the `tenants` and `domains` tables, you can use the migrations that come with this package. If you haven't published them during installation, publish them now:
|
To create the `tenants` and `domains` tables, you can use the migrations that come with this package. If you haven't published them during installation, publish them now:
|
||||||
```
|
```
|
||||||
php artisan vendor:publish --provider='Stancl\Tenancy\TenancyServiceProvider' --tag=migrations
|
php artisan vendor:publish --provider='Stancl\Tenancy\TenancyServiceProvider' --tag=migrations
|
||||||
```
|
```
|
||||||
|
|
||||||
By default, all of your data will be stored in the JSON column `data`. If you want to store some data in a dedicated column (to leverage indexing, for example), add the column to the migration and to `tenancy.custom_columns` config.
|
By default, all of your data will be stored in the JSON column `data`. If you want to store some data in a dedicated column (to leverage indexing, for example), add the column to the migration and to the `tenancy.custom_columns` config.
|
||||||
|
|
||||||
> If you have existing migrations related to your app in `database/migrations`, move them to `database/migrations/tenant`. You can read more about tenant migrations [here]({{ $page->link('tenant-migrations') }}).
|
> If you have existing migrations related to your app in `database/migrations`, move them to `database/migrations/tenant`. You can read more about tenant migrations [here]({{ $page->link('tenant-migrations') }}).
|
||||||
|
|
||||||
|
|
@ -45,7 +45,7 @@ The benefit of this storage driver is its performance.
|
||||||
|
|
||||||
Read the [Redis documentation page on persistence](https://redis.io/topics/persistence). You should definitely use AOF and if you want to be even more protected from data loss, you can use RDB **in conjunction with AOF**.
|
Read the [Redis documentation page on persistence](https://redis.io/topics/persistence). You should definitely use AOF and if you want to be even more protected from data loss, you can use RDB **in conjunction with AOF**.
|
||||||
|
|
||||||
If your cache driver is Redis and you don't want to use AOF with it, run two Redis instances. Otherwise, just make sure you use a different database (number) for tenancy and for anything else.
|
If your cache driver is Redis and you don't want to use AOF with it, run two Redis instances. Otherwise, just make sure you use a different database (number) for tenancy and another for anything else.
|
||||||
|
|
||||||
To use this driver, create a new Redis connection in the `database.redis` configuration (`config/database.php`) called `tenancy`.
|
To use this driver, create a new Redis connection in the `database.redis` configuration (`config/database.php`) called `tenancy`.
|
||||||
|
|
||||||
|
|
@ -57,3 +57,5 @@ To use this driver, create a new Redis connection in the `database.redis` config
|
||||||
'database' => env('TENANCY_REDIS_DB', 3), // alternatively, different database number
|
'database' => env('TENANCY_REDIS_DB', 3), // alternatively, different database number
|
||||||
],
|
],
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> Note: You need phpredis. Predis support will dropped by Laravel in version 7.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue