diff --git a/navigation.php b/navigation.php index 32f9c88..fe542ea 100644 --- a/navigation.php +++ b/navigation.php @@ -156,6 +156,7 @@ return [ 'Tenant Config' => 'features/tenant-config', 'Cross-domain redirect' => 'features/cross-domain-redirect', 'Universal routes' => 'features/universal-routes', + 'Vite bundler' => 'features/vite-bundler', ], ], ], @@ -208,6 +209,7 @@ return [ 'Orchid' => 'integrations/orchid', 'Sanctum' => 'integrations/sanctum', 'Sail' => 'integrations/sail', + 'Vite' => 'features/vite-bundler', ], ], 'Console commands' => 'console-commands', diff --git a/source/docs/v3/console-commands.blade.md b/source/docs/v3/console-commands.blade.md index e330ad0..1aa086c 100644 --- a/source/docs/v3/console-commands.blade.md +++ b/source/docs/v3/console-commands.blade.md @@ -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 diff --git a/source/docs/v3/features/vite-bundler.blade.md b/source/docs/v3/features/vite-bundler.blade.md new file mode 100644 index 0000000..8015a34 --- /dev/null +++ b/source/docs/v3/features/vite-bundler.blade.md @@ -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, +], +``` diff --git a/source/docs/v3/integrating.blade.md b/source/docs/v3/integrating.blade.md index eaaf395..63f6cef 100644 --- a/source/docs/v3/integrating.blade.md +++ b/source/docs/v3/integrating.blade.md @@ -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') }}) diff --git a/source/docs/v3/integrations/passport.blade.md b/source/docs/v3/integrations/passport.blade.md index 6169746..8aee31c 100644 --- a/source/docs/v3/integrations/passport.blade.md +++ b/source/docs/v3/integrations/passport.blade.md @@ -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: diff --git a/source/docs/v3/manual-initialization.md b/source/docs/v3/manual-initialization.md index fea3ac0..c1860d8 100644 --- a/source/docs/v3/manual-initialization.md +++ b/source/docs/v3/manual-initialization.md @@ -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); -``` \ No newline at end of file +``` diff --git a/source/docs/v3/optional-features.blade.md b/source/docs/v3/optional-features.blade.md index 8b8b9e4..f4875ed 100644 --- a/source/docs/v3/optional-features.blade.md +++ b/source/docs/v3/optional-features.blade.md @@ -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. diff --git a/source/docs/v3/tenancy-bootstrappers.blade.md b/source/docs/v3/tenancy-bootstrappers.blade.md index 09ac3c5..3975142 100644 --- a/source/docs/v3/tenancy-bootstrappers.blade.md +++ b/source/docs/v3/tenancy-bootstrappers.blade.md @@ -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') }}) diff --git a/source/saas-boilerplate.blade.php b/source/saas-boilerplate.blade.php index c4d3dc3..8739225 100644 --- a/source/saas-boilerplate.blade.php +++ b/source/saas-boilerplate.blade.php @@ -215,7 +215,7 @@
- + Purchase
@@ -282,7 +282,7 @@
- + Purchase