mirror of
https://github.com/stancl/tenancy-docs.git
synced 2025-12-12 02:04:03 +00:00
Fix a few things in docs
This commit is contained in:
parent
42e2c51343
commit
072eb36494
11 changed files with 49 additions and 17 deletions
|
|
@ -148,7 +148,16 @@ return [
|
||||||
'Event system' => 'event-system',
|
'Event system' => 'event-system',
|
||||||
'Routes' => 'routes',
|
'Routes' => 'routes',
|
||||||
'Tenancy bootstrappers' => 'tenancy-bootstrappers',
|
'Tenancy bootstrappers' => 'tenancy-bootstrappers',
|
||||||
'Feature classes' => 'feature-classes',
|
'Optional Features' => [
|
||||||
|
'url' => 'optional-features',
|
||||||
|
'children' => [
|
||||||
|
'User impersonation' => 'features/user-impersonation',
|
||||||
|
'Telescope tags' => 'features/telescope-tags',
|
||||||
|
'Tenant Config' => 'features/tenant-config',
|
||||||
|
'Cross-domain redirect' => 'features/cross-domain-redirect',
|
||||||
|
'Universal routes' => 'features/universal-routes',
|
||||||
|
],
|
||||||
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
@ -187,7 +196,17 @@ return [
|
||||||
'children' => [
|
'children' => [
|
||||||
'Manual initialization' => 'manual-initialization',
|
'Manual initialization' => 'manual-initialization',
|
||||||
'Testing' => 'testing',
|
'Testing' => 'testing',
|
||||||
'Integrating with other packages' => 'integrating',
|
'Integrating with other packages' => [
|
||||||
|
'url' => 'integrating',
|
||||||
|
'children' => [
|
||||||
|
'Spatie packages' => 'integrations/spatie',
|
||||||
|
'Horizon' => 'integrations/horizon',
|
||||||
|
'Passport' => 'integrations/passport',
|
||||||
|
'Nova' => 'integrations/nova',
|
||||||
|
'Telescope' => 'integrations/telescope',
|
||||||
|
'Livewire' => 'integrations/livewire',
|
||||||
|
],
|
||||||
|
],
|
||||||
'Console commands' => 'console-commands',
|
'Console commands' => 'console-commands',
|
||||||
'Cached lookup' => 'cached-lookup',
|
'Cached lookup' => 'cached-lookup',
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,22 @@ extends: _layouts.documentation
|
||||||
section: content
|
section: content
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
||||||
# Configuration
|
# Configuration
|
||||||
|
|
||||||
The package is highly configurable. This page covers what you can configure in the `config/tenancy.php` file, but note that many more things are configurable. Some things can be changed by extending classes (e.g. the `Tenant` model), and **many** things can be changed using static properties. These things will *usually* be mentioned on the respective pages of the documentation, but not every time. For this reason, don't be afraid to dive into the package's source code — whenever the class you're using has a `public static` property, **it's intended to be configured**.
|
The package is highly configurable. This page covers what you can configure in the `config/tenancy.php` file, but note that many more things are configurable. Some things can be changed by extending classes (e.g. the `Tenant` model), and **many** things can be changed using static properties. These things will *usually* be mentioned on the respective pages of the documentation, but not every time. For this reason, don't be afraid to dive into the package's source code — whenever the class you're using has a `public static` property, **it's intended to be configured**.
|
||||||
|
|
||||||
|
## Static properties
|
||||||
|
|
||||||
|
You can set static properties like this (example):
|
||||||
|
|
||||||
|
```php
|
||||||
|
\Stancl\Tenancy\Middleware\InitializeTenancyByDomain::$onFail = function () {
|
||||||
|
return redirect('https://my-central-domain.com/');
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
A good place to put these calls is your `app/Providers/TenancyServiceProvider`'s `boot()` method.
|
||||||
|
|
||||||
### Tenant model
|
### Tenant model
|
||||||
|
|
||||||
`tenancy.tenant_model`
|
`tenancy.tenant_model`
|
||||||
|
|
@ -87,7 +98,7 @@ See this section in the config, it's documented with comments.
|
||||||
|
|
||||||
`tenancy.features`
|
`tenancy.features`
|
||||||
|
|
||||||
This config array lets you enable, disable or add your own [feature classes]({{ $page->link('feature-classes') }}).
|
This config array lets you enable, disable or add your own [feature classes]({{ $page->link('optional-features') }}).
|
||||||
|
|
||||||
### Migration parameters
|
### Migration parameters
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ Conversely, when the `TenancyEnded` event fires, the `RevertToCentralContext` ev
|
||||||
|
|
||||||
# Job pipelines
|
# Job pipelines
|
||||||
|
|
||||||
You may job pipelines even in projects that don't use this package — we think they're a cool concept so they're extracted into a separate package: [github.com/stancl/jobpipeline](https://github.com/stancl/jobpipeline)
|
You may want to use job pipelines even in projects that don't use this package — we think they're a cool concept so they're extracted into a separate package: [github.com/stancl/jobpipeline](https://github.com/stancl/jobpipeline)
|
||||||
|
|
||||||
The `JobPipeline` is a simple, yet **extremely powerful** class that lets you **convert any (series of) jobs into event listeners.**
|
The `JobPipeline` is a simple, yet **extremely powerful** class that lets you **convert any (series of) jobs into event listeners.**
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,8 @@ mv database/migrations/*_create_permission_tables.php database/migrations/tenant
|
||||||
Then add this to your `AppServiceProvider::boot()` method:
|
Then add this to your `AppServiceProvider::boot()` method:
|
||||||
|
|
||||||
```php
|
```php
|
||||||
Event::listen(TenancyBootstrapped::class, function (Tenancy $tenancy) {
|
Event::listen(TenancyBootstrapped::class, function (TenancyBootstrapped $event) {
|
||||||
\Spatie\Permission\PermissionRegistrar::$cacheKey = 'spatie.permission.cache.tenant.' . $tenancy->tenant->id;
|
\Spatie\Permission\PermissionRegistrar::$cacheKey = 'spatie.permission.cache.tenant.' . $event->tenancy->tenant->id;
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
---
|
---
|
||||||
title: Feature classes
|
title: Optional features
|
||||||
extends: _layouts.documentation
|
extends: _layouts.documentation
|
||||||
section: content
|
section: content
|
||||||
---
|
---
|
||||||
|
|
||||||
# Feature classes
|
# Optional features
|
||||||
|
|
||||||
"Features" are classes that provide additional functionality that's not needed for the core tenancy logic. Out of the box, the package comes with these Features:
|
"Features" are classes that provide additional functionality that's not needed for the core tenancy logic. Out of the box, the package comes with these Features:
|
||||||
|
|
||||||
|
|
@ -77,3 +77,5 @@ Due to the order in which the service providers (and as such, their routes) are
|
||||||
However, tenant routes that don't have their central counterpart will still be accessible on central domains and will result in a "Tenant could not be identified on domain ..." error. To avoid this, use the `Stancl\Tenancy\Middleware\PreventAccessFromCentralDomains` middleware on all of your tenant routes. This middleware will abort with a 404 if the user is trying to visit a tenant route on a central domain.
|
However, tenant routes that don't have their central counterpart will still be accessible on central domains and will result in a "Tenant could not be identified on domain ..." error. To avoid this, use the `Stancl\Tenancy\Middleware\PreventAccessFromCentralDomains` middleware on all of your tenant routes. This middleware will abort with a 404 if the user is trying to visit a tenant route on a central domain.
|
||||||
|
|
||||||
## Universal routes
|
## Universal routes
|
||||||
|
|
||||||
|
See the [Universal Routes feature]({{ $page->link('features/universal-routes') }}).
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ section: content
|
||||||
|
|
||||||
If you'd like to share certain resources, usually users, between tenant databases, you can use our resource syncing feature. This will let you **sync specific columns between specific tenant databases and the central database.**
|
If you'd like to share certain resources, usually users, between tenant databases, you can use our resource syncing feature. This will let you **sync specific columns between specific tenant databases and the central database.**
|
||||||
|
|
||||||
|
This is a relatively complex feature, so before implementing it, make sure you really need it. You only need this feature if you're using multi-database tenancy and need to sync specific resources (like users) between different tenants' databases.
|
||||||
|
|
||||||
## Database
|
## Database
|
||||||
|
|
||||||
The resource exists in the central database, for example a `users` table. Another table exists in the tenants' databases. It can use the same name as the central database or a different name — up to you.
|
The resource exists in the central database, for example a `users` table. Another table exists in the tenants' databases. It can use the same name as the central database or a different name — up to you.
|
||||||
|
|
@ -172,7 +174,7 @@ Here's how it will work:
|
||||||
tenancy()->initialize($tenant);
|
tenancy()->initialize($tenant);
|
||||||
|
|
||||||
// Create the same user in tenant DB
|
// Create the same user in tenant DB
|
||||||
$user = TenantUser::create([
|
$user = User::create([
|
||||||
'global_id' => 'acme',
|
'global_id' => 'acme',
|
||||||
'name' => 'John Doe',
|
'name' => 'John Doe',
|
||||||
'email' => 'john@localhost',
|
'email' => 'john@localhost',
|
||||||
|
|
|
||||||
|
|
@ -102,9 +102,7 @@ Keys that start with the internal prefix (`tenancy_` by default, but you can cus
|
||||||
|
|
||||||
## Events
|
## Events
|
||||||
|
|
||||||
The `Tenant` model dispatches Eloquent events, all of which have their own respective class. You can read more about this on the *Event system* page.
|
The `Tenant` model dispatches Eloquent events, all of which have their own respective class. You can read more about this on the [Event system]({{ $page->link('event-system') }}) page.
|
||||||
|
|
||||||
[Event system]({{ $page->link('event-system') }})
|
|
||||||
|
|
||||||
## Accessing the current tenant
|
## Accessing the current tenant
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ Contact me on [samuel@tenancyforlaravel.com](mailto:samuel@tenancyforlaravel.com
|
||||||
|
|
||||||
If you're a business making a donation, you may want an invoice.
|
If you're a business making a donation, you may want an invoice.
|
||||||
|
|
||||||
Contact me on [samuel@tenancyforlaravel.com](mailto:samuel@tenancyforlaravel.com?subject=Donation%20with%20invoice) and let me know what you need to have on the invoice and I will make it happen.
|
Contact me on [samuel@tenancyforlaravel.com](mailto:samuel@tenancyforlaravel.com?subject=Donation%20with%20invoice), let me know what you need to have on the invoice and I will make it happen.
|
||||||
|
|
||||||
### Thank you!
|
### Thank you!
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue