@@ 79-96 (lines=18) @@ | ||
76 | ||
77 | $add_to_tenant = $this->anticipate('Would you like to assign the user to a tenant?', ['Yes', 'No'], 'Yes'); |
|
78 | ||
79 | if ($add_to_tenant == 'Yes') { |
|
80 | $headers = ['Name', 'ID']; |
|
81 | $tenants = config('multi-tenant.tenant_class')::all('name', 'id'); |
|
82 | ||
83 | if($tenants->count() <= 0) { |
|
84 | $this->comment($user->email . ' with the password `tester` was created without any tenants'); |
|
85 | } else { |
|
86 | $this->table($headers, $tenants->toArray()); |
|
87 | ||
88 | $tenant_id = (int) $this->ask('Please enter the id of the desired tenant.'); |
|
89 | ||
90 | $tenant = config('multi-tenant.tenant_class')::findOrFail($tenant_id); |
|
91 | ||
92 | $tenant->update(['owner_id' => $user->id]); |
|
93 | ||
94 | $this->comment('The user ' . $user->email . ' is now the owner of ' . $tenant->name . ' with the password `tester`'); |
|
95 | } |
|
96 | } |
|
97 | } |
|
98 | ||
99 | /** |
|
@@ 117-137 (lines=21) @@ | ||
114 | ||
115 | $add_to_tenant = $this->anticipate('Would you like to assign the user to a tenant?', ['Yes', 'No'], 'Yes'); |
|
116 | ||
117 | if ($add_to_tenant == 'Yes') { |
|
118 | $headers = ['Name', 'ID']; |
|
119 | $tenants = config('multi-tenant.tenant_class')::all('name', 'id'); |
|
120 | ||
121 | if($tenants->count() <= 0) { |
|
122 | $this->comment($user->email . ' with the password `tester` was created without any tenants'); |
|
123 | } else { |
|
124 | $this->table($headers, $tenants->toArray()); |
|
125 | ||
126 | $tenant_id = (int) $this->ask('Please enter the id of the desired tenant.'); |
|
127 | ||
128 | $tenant = config('multi-tenant.tenant_class')::findOrFail($tenant_id); |
|
129 | ||
130 | $tenant->update(['owner_id' => $user->id]); |
|
131 | ||
132 | $this->comment('The user ' . $user->email . ' is now the owner of ' . $tenant->name . ' with the password `tester`'); |
|
133 | } |
|
134 | } |
|
135 | else{ |
|
136 | $this->comment($user->email . ' with the password `tester` was created without any tenants'); |
|
137 | } |
|
138 | ||
139 | } |
|
140 | } |