Improve Orchid integration docs page (#176)

* Improve Orchid integration docs page

Rewrote the docs and removed some bits because they seemed extra (like changing `HOME` or prefixing the tenant routes).

* Fix typo

* Add note about possible error

* Update hyperlink
This commit is contained in:
lukinovec 2022-07-20 16:07:56 +02:00 committed by GitHub
parent 5c7e4b2533
commit d67116163d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,23 +6,24 @@ section: content
# Laravel Orchid {#laravel-orchid} # Laravel Orchid {#laravel-orchid}
The instruction is written for a newly installed Orchid platform, it is proposed to use the platform as a central application and the tenant app. First, set up tenancy following the [quickstart guide]({{ $page->link('quickstart') }}), and install [Laravel Orchid](https://orchid.software/en/docs/installation/).
## Both in the central app and the tenant app To use Orchid both in the central and the tenant app:
Laravel Orchid has already been installed according to the [documentation Orchid](https://orchid.software/en/docs/installation/). All the steps have also been completed [Quickstart Tutorial](/docs/v3/quickstart). Copy the user and Orchid migrations to `migrations\tenant`
- To use Orchid both in the central & tenant parts you need to enable [Universal Routes]({{ $page->link('features/universal-routes') }}). - Enable [universal routes]({{ $page->link('features/universal-routes') }})
- Add the tenancy middleware to your `config\platform.php`
- Add your tenant identification middleware to `config\platform.php` (feel free to use a different identification middleware):
```php ```php
'middleware' => [ 'middleware' => [
'public' => ['web', 'universal', \Stancl\Tenancy\Middleware\InitializeTenancyByDomain::class], 'public' => ['web', 'universal', InitializeTenancyByDomain::class], // Don't forget to import the middleware
'private' => ['web', 'platform', 'universal', \Stancl\Tenancy\Middleware\InitializeTenancyByDomain::class], 'private' => ['web', 'platform', 'universal', InitializeTenancyByDomain::class],
], ],
``` ```
- Add a route to `routes\platform.php` - Add a route to `routes\platform.php`:
```php ```php
Route::screen('/', PlatformScreen::class) Route::screen('/', PlatformScreen::class)
@ -32,13 +33,7 @@ Laravel Orchid has already been installed according to the [documentation Orchid
}); });
``` ```
- In the file `app\Providers\RouteServiceProvider.php`, if necessary, change the path to the "home" route for your central application. By default for Orchid it will be `'admin/main'` - Add 'platform' middleware to your tenant routes (`routes\tenant.php`):
```php
public const HOME = 'admin/main';
```
- Tenant Routes `routes\tenant.php`
```php ```php
Route::middleware([ Route::middleware([
@ -46,9 +41,7 @@ Laravel Orchid has already been installed according to the [documentation Orchid
'platform', 'platform',
InitializeTenancyByDomain::class, InitializeTenancyByDomain::class,
PreventAccessFromCentralDomains::class, PreventAccessFromCentralDomains::class,
])->prefix(Orchid\Platform\Dashboard::prefix('/'))->group(function () { ]);
Route::get('/', function () {
return 'This is your multi-tenant application. The id of the current tenant is ' . tenant('id');
});
});
``` ```
- If listing users in the admin panel throws an exception, change line 55 in the UserListLayout class to `return $user->updated_at?->toDateTimeString()` (add null-safe operator)