1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-16 10:44:05 +00:00

Refactor models & config

This commit is contained in:
Samuel Štancl 2020-05-24 20:40:10 +02:00
parent f0ff8248e7
commit 2839f45196
9 changed files with 123 additions and 97 deletions

View file

@ -0,0 +1,26 @@
<?php
namespace Stancl\Tenancy\Database\Concerns;
use Stancl\Tenancy\Contracts\Tenant;
trait TenantRun
{
public function run(callable $callback)
{
/** @var Tenant $this */
$originalTenant = tenant();
tenancy()->initialize($this);
$result = $callback($this);
if ($originalTenant) {
tenancy()->initialize($originalTenant);
} else {
tenancy()->end();
}
return $result;
}
}