From 3e5d4ad7b8bce0a470775669b19b6840fd13b494 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Fri, 23 Aug 2019 22:40:08 +0200 Subject: [PATCH] Misc tips --- navigation.php | 1 + source/docs/misc-tips.md | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 source/docs/misc-tips.md diff --git a/navigation.php b/navigation.php index 88d9bde0..34b4269f 100644 --- a/navigation.php +++ b/navigation.php @@ -44,6 +44,7 @@ return [ 'Tips' => [ 'children' => [ 'HTTPS Certificates' => 'docs/https-certificates', + 'Misc' => 'docs/misc-tips', ], ], 'Stay Updated' => 'docs/stay-updated', diff --git a/source/docs/misc-tips.md b/source/docs/misc-tips.md new file mode 100644 index 00000000..fc0ce0ee --- /dev/null +++ b/source/docs/misc-tips.md @@ -0,0 +1,34 @@ +--- +title: Miscellaneous Tips +description: Miscellaneous Tips | stancl/tenancy — A Laravel multi-database tenancy package that respects your code.. +extends: _layouts.documentation +section: content +--- + +# Miscellaneous Tips {#misc-tips} + +## Tenant Redirect {#tenant-redirect} + +A customer has signed up on your website, you have created a new tenant and now you want to redirect the customer to their website. You can use the `tenant()` method on Redirect, like this: + +```php +// tenant sign up controller +return redirect()->route('dashboard')->tenant($tenant['domain']); +``` + +## Custom ID scheme + +If you don't want to use UUIDs and want to use something more human-readable (even domain concatenated with uuid, for example), you can create a custom class for this: + +```php +class MyUniqueIDGenerator implements UniqueIdentifierGenerator +{ + public static function handle(string $domain, array $data): string + { + return $domain . \Webpatser\Uuid\Uuid::generate(1, $domain); + } +} +``` + +and then set the `tenancy.unique_id_generator` config to the full path to your class. +