Merge branch 'master' into sail-docs

This commit is contained in:
Chinmay Purav 2022-10-12 01:36:43 +05:30 committed by GitHub
commit f1bae7e14e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 55 additions and 12 deletions

View file

@ -156,6 +156,7 @@ return [
'Tenant Config' => 'features/tenant-config', 'Tenant Config' => 'features/tenant-config',
'Cross-domain redirect' => 'features/cross-domain-redirect', 'Cross-domain redirect' => 'features/cross-domain-redirect',
'Universal routes' => 'features/universal-routes', 'Universal routes' => 'features/universal-routes',
'Vite bundler' => 'features/vite-bundler',
], ],
], ],
], ],
@ -208,6 +209,7 @@ return [
'Orchid' => 'integrations/orchid', 'Orchid' => 'integrations/orchid',
'Sanctum' => 'integrations/sanctum', 'Sanctum' => 'integrations/sanctum',
'Sail' => 'integrations/sail', 'Sail' => 'integrations/sail',
'Vite' => 'features/vite-bundler',
], ],
], ],
'Console commands' => 'console-commands', 'Console commands' => 'console-commands',

View file

@ -15,7 +15,7 @@ Tenant-aware commands run for all tenants by default. The commands also have the
## **Migrate** (tenant-aware) {#migrate} ## **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 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 '--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 php artisan tenants:list

View 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,
],
```

View file

@ -17,3 +17,4 @@ If you're using the [automatic mode]({{ $page->link('automatic-mode') }}) & [mul
- [Livewire]({{ $page->link('integrations/livewire') }}) - [Livewire]({{ $page->link('integrations/livewire') }})
- [Laravel Sanctum]({{ $page->link('integrations/sanctum') }}) - [Laravel Sanctum]({{ $page->link('integrations/sanctum') }})
- [Laravel Sail]({{ $page->link('integrations/sail') }}) - [Laravel Sail]({{ $page->link('integrations/sail') }})
- [Vite]({{ $page->link('features/vite-bundler') }})

View file

@ -29,11 +29,9 @@ 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`. 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:
5. Register the Passport routes in your `AuthServiceProvider` by adding the following code to the provider's `boot` method.
```php ```php
Passport::routes(null, ['middleware' => [ Passport::routes(null, ['middleware' => [
InitializeTenancyByDomain::class, // Or other identification middleware of your choice InitializeTenancyByDomain::class, // Or other identification middleware of your choice
@ -41,7 +39,25 @@ To use Passport inside the tenant part of your application, you may do the follo
]]); ]]);
``` ```
6. Set up [the encryption keys](#passport-encryption-keys).
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. 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} ## **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: 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:

View file

@ -6,7 +6,7 @@ section: content
# Manual initialization {#manual-initialization} # 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. For that, use the `initialize()` method on `Stancl\Tenancy\Tenancy`. You can resolve the `Tenancy` instance out of the container using the `tenancy()` helper.

View file

@ -13,6 +13,8 @@ section: content
- [`TenantConfig`]({{ $page->link('features/tenant-config') }}) for mapping keys from the tenant storage into the application config - [`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 - [`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 - [`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. 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. You may register features by adding their class names to the `tenancy.features` config.

View file

@ -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. 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: You can read more about this on the *Queues* page:
[Queues]({{ $page->link('queues') }}) [Queues]({{ $page->link('queues') }})

View file

@ -215,7 +215,7 @@
</li> </li>
</ul> </ul>
<div class="mt-6 rounded-md shadow"> <div class="mt-6 rounded-md shadow">
<a target="_blank" href="https://gumroad.com/l/saas-boilerplate?offer_code=launch-website&wanted=true" data-gumroad-single-product="true" class="flex items-center justify-center px-5 py-3 border border-transparent text-base leading-6 font-medium rounded-md text-white bg-gray-900 hover:bg-gray-800 focus:outline-none focus:shadow-outline transition duration-150 ease-in-out" aria-describedby="tier-standard"> <a target="_blank" href="https://app.gumroad.com/checkout?offer_code=launch-website&wanted=true&product=adAZB&quantity=1&code=launch-website&referrer=" data-gumroad-single-product="true" class="flex items-center justify-center px-5 py-3 border border-transparent text-base leading-6 font-medium rounded-md text-white bg-gray-900 hover:bg-gray-800 focus:outline-none focus:shadow-outline transition duration-150 ease-in-out" aria-describedby="tier-standard">
Purchase Purchase
</a> </a>
</div> </div>
@ -282,7 +282,7 @@
</li> </li>
</ul> </ul>
<div class="mt-6 rounded-md shadow"> <div class="mt-6 rounded-md shadow">
<a target="_blank" href="https://gumroad.com/l/saas-boilerplate-enterprise?offer_code=launch-website&wanted=true" data-gumroad-single-product="true" class="flex items-center justify-center px-5 py-3 border border-transparent text-base leading-6 font-medium rounded-md text-white bg-gray-900 hover:bg-gray-800 focus:outline-none focus:shadow-outline transition duration-150 ease-in-out" aria-describedby="tier-enterprise"> <a target="_blank" href="https://app.gumroad.com/checkout?wanted=true&offer_code=launch-website&product=FeNvZ&quantity=1&code=launch-website&referrer=" data-gumroad-single-product="true" class="flex items-center justify-center px-5 py-3 border border-transparent text-base leading-6 font-medium rounded-md text-white bg-gray-900 hover:bg-gray-800 focus:outline-none focus:shadow-outline transition duration-150 ease-in-out" aria-describedby="tier-enterprise">
Purchase Purchase
</a> </a>
</div> </div>