mirror of
https://github.com/stancl/tenancy-docs.git
synced 2025-12-12 10:14:03 +00:00
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:
parent
5c7e4b2533
commit
d67116163d
1 changed files with 17 additions and 24 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue