mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 08:14:02 +00:00
allow for custom colums on creation of tenant
This commit is contained in:
parent
cfcb2574c2
commit
1194a08c48
2 changed files with 17 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -7,3 +7,4 @@ psysh
|
||||||
phpunit_var_*.xml
|
phpunit_var_*.xml
|
||||||
coverage/
|
coverage/
|
||||||
clover.xml
|
clover.xml
|
||||||
|
.idea/
|
||||||
|
|
@ -103,7 +103,22 @@ class DatabaseStorageDriver implements StorageDriver
|
||||||
public function createTenant(Tenant $tenant): void
|
public function createTenant(Tenant $tenant): void
|
||||||
{
|
{
|
||||||
$this->centralDatabase->transaction(function () use ($tenant) {
|
$this->centralDatabase->transaction(function () use ($tenant) {
|
||||||
Tenants::create(['id' => $tenant->id, 'data' => json_encode($tenant->data)])->toArray();
|
$custom_columns = Tenants::customColumns();
|
||||||
|
|
||||||
|
$tenant_data = ['id' => $tenant->id];
|
||||||
|
|
||||||
|
$data = collect($tenant->data)
|
||||||
|
->reject(function($value, $key) use ($tenant, $custom_columns, &$tenant_data) {
|
||||||
|
if (isset($custom_columns[$key])) {
|
||||||
|
$tenant_data[$key] = $value;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
})->all();
|
||||||
|
|
||||||
|
$tenant_data['data'] = json_encode($data);
|
||||||
|
|
||||||
|
Tenants::create($tenant_data)->toArray();
|
||||||
|
|
||||||
$domainData = [];
|
$domainData = [];
|
||||||
foreach ($tenant->domains as $domain) {
|
foreach ($tenant->domains as $domain) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue