mirror of
https://github.com/stancl/tenancy-docs.git
synced 2025-12-12 18:24: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
|
|
@ -4,11 +4,22 @@ extends: _layouts.documentation
|
|||
section: content
|
||||
---
|
||||
|
||||
|
||||
# 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**.
|
||||
|
||||
## 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
|
||||
|
||||
`tenancy.tenant_model`
|
||||
|
|
@ -87,7 +98,7 @@ See this section in the config, it's documented with comments.
|
|||
|
||||
`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
|
||||
|
||||
|
|
|
|||
|
|
@ -51,8 +51,8 @@ class PostController
|
|||
{
|
||||
if ($request->has('image')) {
|
||||
$post->image_url = $this->cloudinary()->store(
|
||||
$request->file('image')
|
||||
);
|
||||
$request->file('image')
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ Conversely, when the `TenancyEnded` event fires, the `RevertToCentralContext` ev
|
|||
|
||||
# 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.**
|
||||
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@ mv database/migrations/*_create_permission_tables.php database/migrations/tenant
|
|||
Then add this to your `AppServiceProvider::boot()` method:
|
||||
|
||||
```php
|
||||
Event::listen(TenancyBootstrapped::class, function (Tenancy $tenancy) {
|
||||
\Spatie\Permission\PermissionRegistrar::$cacheKey = 'spatie.permission.cache.tenant.' . $tenancy->tenant->id;
|
||||
Event::listen(TenancyBootstrapped::class, function (TenancyBootstrapped $event) {
|
||||
\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
|
||||
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:
|
||||
|
||||
|
|
@ -76,4 +76,6 @@ 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.
|
||||
|
||||
## 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.**
|
||||
|
||||
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
|
||||
|
||||
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);
|
||||
|
||||
// Create the same user in tenant DB
|
||||
$user = TenantUser::create([
|
||||
$user = User::create([
|
||||
'global_id' => 'acme',
|
||||
'name' => 'John Doe',
|
||||
'email' => 'john@localhost',
|
||||
|
|
|
|||
|
|
@ -102,9 +102,7 @@ Keys that start with the internal prefix (`tenancy_` by default, but you can cus
|
|||
|
||||
## 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.
|
||||
|
||||
[Event system]({{ $page->link('event-system') }})
|
||||
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.
|
||||
|
||||
## Accessing the current tenant
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue