diff --git a/navigation.php b/navigation.php index 069a82c..8b7cf58 100644 --- a/navigation.php +++ b/navigation.php @@ -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', ], diff --git a/source/docs/v3/configuration.blade.md b/source/docs/v3/configuration.blade.md index 00737e7..a5f8961 100644 --- a/source/docs/v3/configuration.blade.md +++ b/source/docs/v3/configuration.blade.md @@ -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 diff --git a/source/docs/v3/early-identification.blade.md b/source/docs/v3/early-identification.blade.md index cf120f3..dff00af 100644 --- a/source/docs/v3/early-identification.blade.md +++ b/source/docs/v3/early-identification.blade.md @@ -51,8 +51,8 @@ class PostController { if ($request->has('image')) { $post->image_url = $this->cloudinary()->store( - $request->file('image') - ); + $request->file('image') + ); } } } diff --git a/source/docs/v3/event-system.blade.md b/source/docs/v3/event-system.blade.md index e3ed4bb..4c285e4 100644 --- a/source/docs/v3/event-system.blade.md +++ b/source/docs/v3/event-system.blade.md @@ -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.** diff --git a/source/docs/v3/integrations/spatie.blade.md b/source/docs/v3/integrations/spatie.blade.md index 1599ca7..05bc65e 100644 --- a/source/docs/v3/integrations/spatie.blade.md +++ b/source/docs/v3/integrations/spatie.blade.md @@ -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; }); ``` diff --git a/source/docs/v3/feature-classes.blade.md b/source/docs/v3/optional-features.md similarity index 96% rename from source/docs/v3/feature-classes.blade.md rename to source/docs/v3/optional-features.md index 82bc4cd..2c4d194 100644 --- a/source/docs/v3/feature-classes.blade.md +++ b/source/docs/v3/optional-features.md @@ -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: diff --git a/source/docs/v3/routes.blade.md b/source/docs/v3/routes.blade.md index a9ad81f..e7dab87 100644 --- a/source/docs/v3/routes.blade.md +++ b/source/docs/v3/routes.blade.md @@ -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 \ No newline at end of file +## Universal routes + +See the [Universal Routes feature]({{ $page->link('features/universal-routes') }}). diff --git a/source/docs/v3/synced-resources-between-tenants.blade.md b/source/docs/v3/synced-resources-between-tenants.blade.md index 9a6d509..beedcd4 100644 --- a/source/docs/v3/synced-resources-between-tenants.blade.md +++ b/source/docs/v3/synced-resources-between-tenants.blade.md @@ -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', diff --git a/source/docs/v3/tenants.blade.md b/source/docs/v3/tenants.blade.md index cb577b5..ebc431c 100644 --- a/source/docs/v3/tenants.blade.md +++ b/source/docs/v3/tenants.blade.md @@ -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 diff --git a/source/docs/v3/upgrading.md b/source/docs/v3/upgrading.blade.md similarity index 100% rename from source/docs/v3/upgrading.md rename to source/docs/v3/upgrading.blade.md diff --git a/source/donate.blade.md b/source/donate.blade.md index 5bf06a0..dd04644 100644 --- a/source/donate.blade.md +++ b/source/donate.blade.md @@ -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!