From 5f9f1415807e8a3622997506d4ded289bb7dd6d6 Mon Sep 17 00:00:00 2001 From: lukinovec Date: Mon, 3 Oct 2022 14:44:02 +0200 Subject: [PATCH 1/7] Add disclaimer about the Passport version (10.x) (#211) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add disclaimer about the Passport version (10.x) The Passport guide was written before the release of 11.x * Update passport.blade.md Co-authored-by: Samuel Štancl --- source/docs/v3/integrations/passport.blade.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/docs/v3/integrations/passport.blade.md b/source/docs/v3/integrations/passport.blade.md index 6169746..0682756 100644 --- a/source/docs/v3/integrations/passport.blade.md +++ b/source/docs/v3/integrations/passport.blade.md @@ -6,6 +6,8 @@ section: content # Laravel Passport {#laravel-passport} +> **Note:** This guide is written for Laravel Passport 10.x + > **Tip:** If you just want to write an SPA application but don't need an API for some other use (e.g., a mobile app), you can avoid a lot of the complexity of writing SPAs by using [Inertia.js](https://inertiajs.com/). > **Another tip:** Using Passport only in the central application doesn't require any additional configuration. You can just install it following [the official Laravel Passport documentation](https://laravel.com/docs/9.x/passport). From 31a64ab28feb29c31bf1248177278d9341b9adc3 Mon Sep 17 00:00:00 2001 From: lukinovec Date: Tue, 4 Oct 2022 19:49:49 +0200 Subject: [PATCH 2/7] Document the ViteBundler feature (#209) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Document the ViteBundler feature * Fix formatting * Remove Vite integration page, make links to the integration page link to the feature page * Add example for enabling the feature * improve writing Co-authored-by: Samuel Štancl --- navigation.php | 2 ++ source/docs/v3/features/vite-bundler.blade.md | 18 ++++++++++++++++++ source/docs/v3/integrating.blade.md | 1 + source/docs/v3/optional-features.blade.md | 2 ++ 4 files changed, 23 insertions(+) create mode 100644 source/docs/v3/features/vite-bundler.blade.md diff --git a/navigation.php b/navigation.php index 1f1befb..fb894b7 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', ], ], ], @@ -207,6 +208,7 @@ return [ 'Livewire' => 'integrations/livewire', 'Orchid' => 'integrations/orchid', 'Sanctum' => 'integrations/sanctum', + 'Vite' => 'features/vite-bundler', ], ], 'Console commands' => 'console-commands', 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 1f3d9dc..cd3f8b4 100644 --- a/source/docs/v3/integrating.blade.md +++ b/source/docs/v3/integrating.blade.md @@ -16,3 +16,4 @@ If you're using the [automatic mode]({{ $page->link('automatic-mode') }}) & [mul - [Laravel Telescope]({{ $page->link('integrations/telescope') }}) - [Livewire]({{ $page->link('integrations/livewire') }}) - [Laravel Sanctum]({{ $page->link('integrations/sanctum') }}) +- [Vite]({{ $page->link('features/vite-bundler') }}) 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. From bff53fc23ea14a82df711d6010e8a96c905ee895 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Wed, 5 Oct 2022 20:26:37 +0200 Subject: [PATCH 3/7] fix purchase URLs --- source/saas-boilerplate.blade.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 @@ @@ -282,7 +282,7 @@ From fe84b4186f8844cbcf672a29f5f718b45ca1bcdb Mon Sep 17 00:00:00 2001 From: lukinovec Date: Thu, 6 Oct 2022 11:36:41 +0200 Subject: [PATCH 4/7] Minor console commands docs improvements (#215) * Make `Tenant list` `List` for consistency, add description to List command * Change ID to tenant key * Update migrate command description * Use IDs instead of tenant keys --- source/docs/v3/console-commands.blade.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 From 5ab19201c121e8f77a0e909d0a4aac5916433bb8 Mon Sep 17 00:00:00 2001 From: lukinovec Date: Mon, 10 Oct 2022 20:37:24 +0200 Subject: [PATCH 5/7] Add paragraph about queue tenancy bootstrapper's `$forceRefresh` (#218) --- source/docs/v3/tenancy-bootstrappers.blade.md | 2 ++ 1 file changed, 2 insertions(+) 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') }}) From bfc1c4f513af3ecae20e84550de23a1b65134096 Mon Sep 17 00:00:00 2001 From: lukinovec Date: Mon, 10 Oct 2022 20:38:21 +0200 Subject: [PATCH 6/7] Add integration guide for Passport 11.x (#217) * Add instructions for Passport 11.x * Fix numbering --- source/docs/v3/integrations/passport.blade.md | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/source/docs/v3/integrations/passport.blade.md b/source/docs/v3/integrations/passport.blade.md index 0682756..8aee31c 100644 --- a/source/docs/v3/integrations/passport.blade.md +++ b/source/docs/v3/integrations/passport.blade.md @@ -6,8 +6,6 @@ section: content # Laravel Passport {#laravel-passport} -> **Note:** This guide is written for Laravel Passport 10.x - > **Tip:** If you just want to write an SPA application but don't need an API for some other use (e.g., a mobile app), you can avoid a lot of the complexity of writing SPAs by using [Inertia.js](https://inertiajs.com/). > **Another tip:** Using Passport only in the central application doesn't require any additional configuration. You can just install it following [the official Laravel Passport documentation](https://laravel.com/docs/9.x/passport). @@ -31,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: From df4a487663db53007520a60dde58f47361a6e6ee Mon Sep 17 00:00:00 2001 From: Tom Croft <28220951+tomcrofty@users.noreply.github.com> Date: Tue, 11 Oct 2022 18:39:14 +0100 Subject: [PATCH 7/7] Use of artisan tinker for manual initialization (#219) Small change but it took a bit for me to figure this one out so I wanted to mention it --- source/docs/v3/manual-initialization.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 +```