Fix a few things in docs

This commit is contained in:
Samuel Štancl 2020-06-13 11:52:10 +02:00
parent 42e2c51343
commit 072eb36494
11 changed files with 49 additions and 17 deletions

View file

@ -148,7 +148,16 @@ return [
'Event system' => 'event-system',
'Routes' => 'routes',
'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' => [
'Manual initialization' => 'manual-initialization',
'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',
'Cached lookup' => 'cached-lookup',
],

View file

@ -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

View file

@ -51,8 +51,8 @@ class PostController
{
if ($request->has('image')) {
$post->image_url = $this->cloudinary()->store(
$request->file('image')
);
$request->file('image')
);
}
}
}

View file

@ -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.**

View file

@ -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;
});
```

View file

@ -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:

View file

@ -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') }}).

View file

@ -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',

View file

@ -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

View file

@ -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.
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!