-
Notifications
You must be signed in to change notification settings - Fork 243
Expand file tree
/
Copy pathTenant.php
More file actions
44 lines (33 loc) · 1.05 KB
/
Tenant.php
File metadata and controls
44 lines (33 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
namespace ProcessMaker\Multitenancy;
use Illuminate\Support\Facades\Crypt;
use ProcessMaker\Application;
use Spatie\Multitenancy\Models\Tenant as SpatieTenant;
class Tenant extends SpatieTenant
{
const BOOTSTRAPPED_TENANT = 'bootstrappedTenant';
protected $guarded = [];
// Non-persistent
public $originalValues = null;
protected $casts = [
'config' => 'array',
'password' => 'encrypted',
];
public static function setBootstrappedTenant(Application $app, ?array $tenantData)
{
$app->instance(self::BOOTSTRAPPED_TENANT, $tenantData);
}
public static function fromBootstrapper()
{
if (app()->has(self::BOOTSTRAPPED_TENANT)) {
$tenant = (new static())->newFromBuilder(app(self::BOOTSTRAPPED_TENANT));
$tenant->originalValues = app(self::BOOTSTRAPPED_TENANT)['original_values'];
return $tenant;
}
return null;
}
public function getOriginalValue($key = null)
{
return $this->originalValues[$key] ?? null;
}
}