D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
3023067
/
cwd
/
www
/
vendor
/
stancl
/
tenancy
/
src
/
Database
/
Concerns
/
Filename :
EnsuresDomainIsNotOccupied.php
back
Copy
<?php declare(strict_types=1); namespace Stancl\Tenancy\Database\Concerns; use Stancl\Tenancy\Exceptions\DomainOccupiedByOtherTenantException; trait EnsuresDomainIsNotOccupied { public static function bootEnsuresDomainIsNotOccupied() { static::saving(function ($self) { if ($domain = $self->newQuery()->where('domain', $self->domain)->first()) { if ($domain->getKey() !== $self->getKey()) { throw new DomainOccupiedByOtherTenantException($self->domain); } } }); } }