mirror of
https://github.com/stancl/tenancy-docs.git
synced 2025-12-12 18:24:03 +00:00
Merge branch 'master' into sail-docs
This commit is contained in:
commit
f1bae7e14e
9 changed files with 55 additions and 12 deletions
|
|
@ -15,7 +15,7 @@ Tenant-aware commands run for all tenants by default. The commands also have the
|
|||
|
||||
## **Migrate** (tenant-aware) {#migrate}
|
||||
|
||||
`tenants:migrate` is the most important command. To use tenants, you have to be able to migrate their databases.
|
||||
The `tenants:migrate` command migrates databases of your tenants.
|
||||
|
||||
```
|
||||
php artisan tenants:migrate --tenants=8075a580-1cb8-11e9-8822-49c5d8f8ff23
|
||||
|
|
@ -60,7 +60,9 @@ Artisan::call('tenants:run', [
|
|||
'--argument' => ['body=We have launched a new feature.'] // Array
|
||||
])
|
||||
```
|
||||
## **Tenant list** {#tenant-list}
|
||||
## **List** {#list}
|
||||
|
||||
The `tenants:list` command lists all existing tenants.
|
||||
|
||||
```
|
||||
php artisan tenants:list
|
||||
|
|
|
|||
18
source/docs/v3/features/vite-bundler.blade.md
Normal file
18
source/docs/v3/features/vite-bundler.blade.md
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
---
|
||||
title: Vite bundler
|
||||
extends: _layouts.documentation
|
||||
section: content
|
||||
---
|
||||
|
||||
# Vite bundler {#vite-bundler}
|
||||
|
||||
Enabling the `ViteBundler` feature makes Vite generate correct asset paths by using the `global_asset()` helper instead of the default `asset()` helper.
|
||||
|
||||
To enable the feature, uncomment `Stancl\Tenancy\Features\ViteBundler::class` in the `features` section of the tenancy config:
|
||||
|
||||
```php
|
||||
'features' => [
|
||||
// [...]
|
||||
Stancl\Tenancy\Features\ViteBundler::class,
|
||||
],
|
||||
```
|
||||
|
|
@ -17,3 +17,4 @@ If you're using the [automatic mode]({{ $page->link('automatic-mode') }}) & [mul
|
|||
- [Livewire]({{ $page->link('integrations/livewire') }})
|
||||
- [Laravel Sanctum]({{ $page->link('integrations/sanctum') }})
|
||||
- [Laravel Sail]({{ $page->link('integrations/sail') }})
|
||||
- [Vite]({{ $page->link('features/vite-bundler') }})
|
||||
|
|
|
|||
|
|
@ -29,19 +29,35 @@ To use Passport inside the tenant part of your application, you may do the follo
|
|||
];
|
||||
```
|
||||
|
||||
3. Prevent Passport migrations from running in the central application by adding `Passport::ignoreMigrations()` to the `register` method in your `AppServiceProvider`.
|
||||
3. Prevent Passport migrations from running in the central application by adding `Passport::ignoreMigrations()` to the `register` method in your `AppServiceProvider`.
|
||||
|
||||
4. Apply Passport migrations by running `php artisan tenants:migrate`.
|
||||
|
||||
5. Register the Passport routes in your `AuthServiceProvider` by adding the following code to the provider's `boot` method.
|
||||
```php
|
||||
4. If you're using Passport 10.x, register the Passport routes in your `AuthServiceProvider` by adding the following code to the provider's `boot` method:
|
||||
```php
|
||||
Passport::routes(null, ['middleware' => [
|
||||
InitializeTenancyByDomain::class, // Or other identification middleware of your choice
|
||||
PreventAccessFromCentralDomains::class,
|
||||
]]);
|
||||
```
|
||||
|
||||
|
||||
5. If you're using Passport 11.x, disable the automatic Passport route registering and register the routes manually by adding the following code to the `register` method in your `AppServiceProvider`:
|
||||
|
||||
```php
|
||||
Passport::$registersRoutes = false;
|
||||
|
||||
Route::group([
|
||||
'as' => 'passport.',
|
||||
'middleware' => [InitializeTenancyByDomain::class], // Use tenancy initialization middleware of your choice
|
||||
'prefix' => config('passport.path', 'oauth'),
|
||||
'namespace' => 'Laravel\Passport\Http\Controllers',
|
||||
], function () {
|
||||
$this->loadRoutesFrom(__DIR__ . "/../../vendor/laravel/passport/src/../routes/web.php");
|
||||
});
|
||||
```
|
||||
|
||||
6. Set up [the encryption keys](#passport-encryption-keys).
|
||||
6. Apply Passport migrations by running `php artisan tenants:migrate`.
|
||||
|
||||
7. Set up [the encryption keys](#passport-encryption-keys).
|
||||
|
||||
## **Using Passport in both the tenant and the central application** {#using-passport-in-both-the-tenant-and-the-central-application}
|
||||
To use Passport in both the tenant and the central application, follow [the steps for using Passport in the tenant appliction](#using-passport-in-the-tenant-application-only) with the following adjustments:
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ section: content
|
|||
|
||||
# Manual initialization {#manual-initialization}
|
||||
|
||||
Sometimes you may want to initialize tenancy manually — that is, not using web middleware, command traits, queue tenancy etc.
|
||||
Sometimes you may want to initialize tenancy manually — that is, not using web middleware, command traits, queue tenancy etc. A common use case for this is if you need to use `artisan tinker` for a specific tenant.
|
||||
|
||||
For that, use the `initialize()` method on `Stancl\Tenancy\Tenancy`. You can resolve the `Tenancy` instance out of the container using the `tenancy()` helper.
|
||||
|
||||
|
|
@ -14,4 +14,4 @@ For that, use the `initialize()` method on `Stancl\Tenancy\Tenancy`. You can res
|
|||
$tenant = Tenant::find('some-id');
|
||||
|
||||
tenancy()->initialize($tenant);
|
||||
```
|
||||
```
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ section: content
|
|||
- [`TenantConfig`]({{ $page->link('features/tenant-config') }}) for mapping keys from the tenant storage into the application config
|
||||
- [`CrossDomainRedirect`]({{ $page->link('features/cross-domain-redirect') }}) for adding a `domain()` macro on `RedirectResponse` letting you change the intended hostname of the generated route
|
||||
- [`UniversalRoutes`]({{ $page->link('features/universal-routes') }}) for route actions that work in both the central & tenant context
|
||||
- [`ViteBundler`]({{ $page->link('features/vite-bundler') }}) for making Vite generate the correct asset paths
|
||||
|
||||
All of the package's Features are in the `Stancl\Tenancy\Features` namespace.
|
||||
|
||||
You may register features by adding their class names to the `tenancy.features` config.
|
||||
|
|
|
|||
|
|
@ -102,6 +102,8 @@ public function boot()
|
|||
|
||||
This bootstrapper adds the current tenant's ID to the queued job payloads, and initializes tenancy based on this ID when jobs are being processed.
|
||||
|
||||
The bootstrapper has a static `$forceRefresh` property which is `false` by default. Setting the property to `true` will make tenancy re-initialize for each queued job. This is useful when you're changing the tenant's state (e.g. properties in the `data` column) and want the next job to initialize tenancy again with the new data. Features like the Tenant Config are only executed when tenancy is initialized, so the re-initialization is needed in some cases.
|
||||
|
||||
You can read more about this on the *Queues* page:
|
||||
|
||||
[Queues]({{ $page->link('queues') }})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue