mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-04 21:24:04 +00:00
begin work on docs
This commit is contained in:
parent
6c3f86a611
commit
9296b3806e
3 changed files with 33 additions and 5 deletions
30
README.md
30
README.md
|
|
@ -340,7 +340,35 @@ Note that deleting a tenant doesn't delete his database. You can do this manuall
|
||||||
|
|
||||||
## Storage driver
|
## Storage driver
|
||||||
|
|
||||||
Currently, only Redis is supported, but you're free to code your own storage driver which follows the `Stancl\Tenancy\Interfaces\StorageDriver` interface. Just point the `tenancy.storage_driver` setting at your driver.
|
### Database
|
||||||
|
|
||||||
|
The database storage driver lets you store information about tenants in a relational database like MySQL, PostgreSQL and SQLite.
|
||||||
|
|
||||||
|
To use this storage driver, publish the `create_tenants_table` migration:
|
||||||
|
|
||||||
|
```
|
||||||
|
php artisan vendor:publish --provider='Stancl\Tenancy\TenancyServiceProvider' --tag=migrations
|
||||||
|
```
|
||||||
|
|
||||||
|
By default, the table contains only `uuid`, `domain` and `data` columns.
|
||||||
|
|
||||||
|
The `data` column is used to store information about a tenant, such as their selected plan, in JSON form. This package does not store anything in the column by default.
|
||||||
|
|
||||||
|
You can store specific keys in your own columns. This is useful if you want to use RDBMS features like indexes.
|
||||||
|
|
||||||
|
If you don't need any custom columns, you can skip the next section and run:
|
||||||
|
|
||||||
|
```
|
||||||
|
php artisan migrate
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Adding your own columns
|
||||||
|
|
||||||
|
To add your own columns, TODO.
|
||||||
|
|
||||||
|
### Redis
|
||||||
|
|
||||||
|
Using Redis as your storage driver is recommended due to its low overhead compared to a relational database like MySQL.
|
||||||
|
|
||||||
**Note that you need to configure persistence on your Redis instance** if you don't want to lose all information about tenants.
|
**Note that you need to configure persistence on your Redis instance** if you don't want to lose all information about tenants.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ use Stancl\Tenancy\Interfaces\TenantModel;
|
||||||
|
|
||||||
class Tenant extends Model implements TenantModel
|
class Tenant extends Model implements TenantModel
|
||||||
{
|
{
|
||||||
protected $dataColumn = 'data';
|
protected $dataColumn = 'data'; // todo load this from config
|
||||||
protected $specialColumns = [];
|
protected $specialColumns = []; // todo load this from config
|
||||||
protected $guarded = [];
|
protected $guarded = [];
|
||||||
protected $primaryKey = 'uuid';
|
protected $primaryKey = 'uuid';
|
||||||
public $incrementing = false;
|
public $incrementing = false;
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'storage_driver' => 'Stancl\Tenancy\StorageDrivers\RedisStorageDriver',
|
'storage_driver' => 'Stancl\Tenancy\StorageDrivers\DatabaseStorageDriver',
|
||||||
'tenant_model' => 'Stancl\Tenancy\Tenant',
|
'tenant_model' => 'Stancl\Tenancy\Tenant',
|
||||||
'tenant_route_namespace' => 'App\Http\Controllers',
|
'tenant_route_namespace' => 'App\Http\Controllers',
|
||||||
'exempt_domains' => [
|
'exempt_domains' => [
|
||||||
// 'localhost',
|
// 'localhost',
|
||||||
],
|
],
|
||||||
'database' => [
|
'database' => [
|
||||||
'based_on' => 'mysql',
|
'based_on' => 'sqlite',
|
||||||
'prefix' => 'tenant',
|
'prefix' => 'tenant',
|
||||||
'suffix' => '',
|
'suffix' => '',
|
||||||
],
|
],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue