|
@@ 64-95 (lines=32) @@
|
| 61 |
|
* |
| 62 |
|
* @return void |
| 63 |
|
*/ |
| 64 |
|
private function createFakeTenant() |
| 65 |
|
{ |
| 66 |
|
$name = $this->faker->name; |
| 67 |
|
|
| 68 |
|
$create_new = $this->anticipate('Would you like to create a new user, or use an existing?', ['New', 'Existing'], 'New'); |
| 69 |
|
|
| 70 |
|
if ($create_new === "New") { |
| 71 |
|
$name = (string) $this->ask('Name'); |
| 72 |
|
$email = (string) $this->ask('E-Mail'); |
| 73 |
|
$user = config('multi-tenant.user_class')::create([ |
| 74 |
|
'name' => $name, |
| 75 |
|
'email' => $email, |
| 76 |
|
'password' => bcrypt('tester'), |
| 77 |
|
]); |
| 78 |
|
} else { |
| 79 |
|
$headers = ['Name', 'ID']; |
| 80 |
|
$tenants = config('multi-tenant.user_class')::all('name', 'id'); |
| 81 |
|
$this->table($headers, $tenants->toArray()); |
| 82 |
|
|
| 83 |
|
$user_id = (int) $this->ask('Please enter the id of the desired user.'); |
| 84 |
|
|
| 85 |
|
$user = config('multi-tenant.user_class')::findOrFail($user_id); |
| 86 |
|
} |
| 87 |
|
|
| 88 |
|
$tenant = config('multi-tenant.tenant_class')::create([ |
| 89 |
|
'name' => $name, |
| 90 |
|
'owner_id' => $user->id, |
| 91 |
|
'slug' => str_slug($name) |
| 92 |
|
]); |
| 93 |
|
|
| 94 |
|
$this->comment('The user ' . $user->email . ' is now the owner of ' . $tenant->name . ' with the password `tester`'); |
| 95 |
|
} |
| 96 |
|
|
| 97 |
|
/** |
| 98 |
|
* Setup a new tenant with user supplied settings for the tenant |
|
@@ 102-134 (lines=33) @@
|
| 99 |
|
* |
| 100 |
|
* @return void |
| 101 |
|
*/ |
| 102 |
|
private function createNewTenant() |
| 103 |
|
{ |
| 104 |
|
|
| 105 |
|
$tenant_name = (string) $this->ask('Please enter a name for your new tenant.'); |
| 106 |
|
|
| 107 |
|
$create_new = $this->anticipate('Would you like to create a new user, or use an existing?', ['New', 'Existing'], 'New'); |
| 108 |
|
|
| 109 |
|
if ($create_new === "New") { |
| 110 |
|
$user_name = (string) $this->ask('Please enter a name for the new user'); |
| 111 |
|
$user_email = (string) $this->ask('Please enter an e-mail for the new user'); |
| 112 |
|
$user = config('multi-tenant.user_class')::create([ |
| 113 |
|
'name' => $user_name, |
| 114 |
|
'email' => $user_email, |
| 115 |
|
'password' => bcrypt('tester'), |
| 116 |
|
]); |
| 117 |
|
} else { |
| 118 |
|
$headers = ['Name', 'ID']; |
| 119 |
|
$tenants = config('multi-tenant.user_class')::all('name', 'id'); |
| 120 |
|
$this->table($headers, $tenants->toArray()); |
| 121 |
|
|
| 122 |
|
$user_id = (int) $this->ask('Please enter the id of the desired user.'); |
| 123 |
|
|
| 124 |
|
$user = config('multi-tenant.user_class')::findOrFail($user_id); |
| 125 |
|
} |
| 126 |
|
|
| 127 |
|
$tenant = config('multi-tenant.tenant_class')::create([ |
| 128 |
|
'name' => $tenant_name, |
| 129 |
|
'owner_id' => $user->id, |
| 130 |
|
'slug' => str_slug($tenant_name) |
| 131 |
|
]); |
| 132 |
|
|
| 133 |
|
$this->comment('The user ' . $user->email . ' is now the owner of ' . $tenant->name . ' with the password `tester`'); |
| 134 |
|
} |
| 135 |
|
|
| 136 |
|
} |
| 137 |
|
|