mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 15:34:03 +00:00
17 lines
441 B
PHP
17 lines
441 B
PHP
<?php
|
|
|
|
namespace Stancl\Tenancy\Database\Models\Concerns;
|
|
|
|
use Stancl\Tenancy\Contracts\UniqueIdentifierGenerator;
|
|
|
|
trait GeneratesIds
|
|
{
|
|
public static function bootGeneratesIds()
|
|
{
|
|
static::creating(function (self $model) {
|
|
if (! $model->id && app()->bound(UniqueIdentifierGenerator::class)) {
|
|
$model->id = app(UniqueIdentifierGenerator::class)->generate($model);
|
|
}
|
|
});
|
|
}
|
|
}
|