mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-16 10:44:05 +00:00
Refactor more old code and get tests to pass
This commit is contained in:
parent
c5377a16f7
commit
c32f229dd5
72 changed files with 425 additions and 531 deletions
22
src/Database/Concerns/GeneratesIds.php
Normal file
22
src/Database/Concerns/GeneratesIds.php
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace Stancl\Tenancy\Database\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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function getIncrementing()
|
||||
{
|
||||
return ! app()->bound(UniqueIdentifierGenerator::class);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue