tenancy-docs/docs/source/v2/misc-tips.blade.md
2019-10-20 16:09:31 +02:00

1.3 KiB

title description extends section
Miscellaneous Tips Miscellaneous Tips.. _layouts.documentation content

Miscellaneous Tips

Tenant Redirect

To enable this feature, uncomment the Stancl\Tenancy\Features\TenantRedirect::class line in your tenancy.features config.

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:

// tenant sign up controller
return redirect()->route('dashboard')->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:

use Stancl\Tenancy\Interfaces\UniqueIdentifierGenerator;

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.

Note that you may have to make the id column on the tenants table larger, as it's set to the exact length of uuids by default.