mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 11:34:03 +00:00
vague first draft of v3. TenantModelTest is passing
This commit is contained in:
parent
c2c90ff755
commit
bd9aad229b
56 changed files with 803 additions and 1366 deletions
39
src/Tenancy.php
Normal file
39
src/Tenancy.php
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace Stancl\Tenancy;
|
||||
|
||||
use Stancl\Tenancy\Contracts\TenancyBootstrapper;
|
||||
use Stancl\Tenancy\Database\Models\Tenant;
|
||||
|
||||
class Tenancy
|
||||
{
|
||||
/** @var Tenant|null */
|
||||
public $tenant;
|
||||
|
||||
/** @var callable|null */
|
||||
public static $getBootstrappers = null;
|
||||
|
||||
public function initialize(Tenant $tenant): void
|
||||
{
|
||||
$this->tenant = $tenant;
|
||||
|
||||
event(new Events\TenancyInitialized($tenant));
|
||||
}
|
||||
|
||||
public function end(): void
|
||||
{
|
||||
event(new Events\TenancyEnded($this->tenant));
|
||||
|
||||
$this->tenant = null;
|
||||
}
|
||||
|
||||
/** @return TenancyBootstrapper[] */
|
||||
public function getBootstrappers(): array
|
||||
{
|
||||
$resolve = static::$getBootstrappers ?? function (Tenant $tenant) {
|
||||
return config('tenancy.bootstrappers');
|
||||
};
|
||||
|
||||
return $resolve($this->tenant);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue