From d67116163dfb2c2a483ef61e87e295bc1222e7b7 Mon Sep 17 00:00:00 2001 From: lukinovec Date: Wed, 20 Jul 2022 16:07:56 +0200 Subject: [PATCH] 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 --- source/docs/v3/integrations/orchid.blade.md | 41 +++++++++------------ 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/source/docs/v3/integrations/orchid.blade.md b/source/docs/v3/integrations/orchid.blade.md index de7c1f8..2f6420a 100644 --- a/source/docs/v3/integrations/orchid.blade.md +++ b/source/docs/v3/integrations/orchid.blade.md @@ -6,39 +6,34 @@ section: content # 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') }}). -- Add the tenancy middleware to your `config\platform.php` +- Enable [universal routes]({{ $page->link('features/universal-routes') }}) + +- Add your tenant identification middleware to `config\platform.php` (feel free to use a different identification middleware): ```php 'middleware' => [ - 'public' => ['web', 'universal', \Stancl\Tenancy\Middleware\InitializeTenancyByDomain::class], - 'private' => ['web', 'platform', 'universal', \Stancl\Tenancy\Middleware\InitializeTenancyByDomain::class], + 'public' => ['web', 'universal', InitializeTenancyByDomain::class], // Don't forget to import the middleware + 'private' => ['web', 'platform', 'universal', InitializeTenancyByDomain::class], ], ``` -- Add a route to `routes\platform.php` +- Add a route to `routes\platform.php`: ```php Route::screen('/', PlatformScreen::class) - ->name('platform.index') - ->breadcrumbs(function (Trail $trail) { - return $trail->push(__('Home'), route('platform.index')); - }); + ->name('platform.index') + ->breadcrumbs(function (Trail $trail) { + return $trail->push(__('Home'), route('platform.index')); + }); ``` -- 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'` - - ```php - public const HOME = 'admin/main'; - ``` - -- Tenant Routes `routes\tenant.php` +- Add 'platform' middleware to your tenant routes (`routes\tenant.php`): ```php Route::middleware([ @@ -46,9 +41,7 @@ Laravel Orchid has already been installed according to the [documentation Orchid 'platform', InitializeTenancyByDomain::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)