1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 17:44:04 +00:00
tenancy/src/UniqueIdentifierGenerators/RandomStringGenerator.php

25 lines
650 B
PHP

<?php
declare(strict_types=1);
namespace Stancl\Tenancy\UniqueIdentifierGenerators;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
use Stancl\Tenancy\Contracts\UniqueIdentifierGenerator;
/**
* Generates a cryptographically secure random string for the tenant key.
*
* To customize the string length, change the static `$length` property.
* The number of unique combinations is 61 ^ string length.
*/
class RandomStringGenerator implements UniqueIdentifierGenerator
{
public static int $length = 8;
public static function generate(Model $model): string
{
return Str::random(static::$length);
}
}