tenancy-docs/source/docs/v3/integrations/orchid.blade.md
lukinovec d67116163d
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
2022-07-20 16:07:56 +02:00

47 lines
1.5 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: Laravel Orchid integration
extends: _layouts.documentation
section: content
---
# Laravel Orchid {#laravel-orchid}
First, set up tenancy following the [quickstart guide]({{ $page->link('quickstart') }}), and install [Laravel Orchid](https://orchid.software/en/docs/installation/).
To use Orchid both in the central and the tenant app:
Copy the user and Orchid migrations to `migrations\tenant`
- 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', InitializeTenancyByDomain::class], // Don't forget to import the middleware
'private' => ['web', 'platform', 'universal', InitializeTenancyByDomain::class],
],
```
- 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'));
});
```
- Add 'platform' middleware to your tenant routes (`routes\tenant.php`):
```php
Route::middleware([
'web',
'platform',
InitializeTenancyByDomain::class,
PreventAccessFromCentralDomains::class,
]);
```
- 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)