Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117871053
D4761.1775328407.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
D4761.1775328407.diff
View Options
diff --git a/src/app/Console/Commands/Tenant/CreateCommand.php b/src/app/Console/Commands/Tenant/CreateCommand.php
--- a/src/app/Console/Commands/Tenant/CreateCommand.php
+++ b/src/app/Console/Commands/Tenant/CreateCommand.php
@@ -13,14 +13,14 @@
*
* @var string
*/
- protected $signature = 'tenant:create {user} {--title=}';
+ protected $signature = 'tenant:create {user} {domain} {--title=} {--password=}';
/**
* The console command description.
*
* @var string
*/
- protected $description = "Create a tenant (with a set of SKUs/plans/packages) and make the user a reseller.";
+ protected $description = "Create a tenant (with a set of SKUs/plans/packages), and a reseller user and domain for it.";
/**
* Execute the console command.
@@ -29,11 +29,12 @@
*/
public function handle()
{
- $user = $this->getUser($this->argument('user'));
+ $user = \App\User::where('email', $this->argument('user'))->first();
if (!$user) {
- $this->error('User not found.');
- return 1;
+ $user = new \App\User();
+ $user->email = $this->argument('user');
+ $user->password = $this->option('password');
}
DB::beginTransaction();
@@ -162,5 +163,36 @@
}
$this->info("Created tenant {$tenant->id}.");
+
+ // Set up the primary tenant domain
+ $domain = \App\Domain::where('namespace', $this->argument('domain'))->first();
+ if (!$domain) {
+ // Set up the primary tenant domain
+ $domain = \App\Domain::create(
+ [
+ 'namespace' => $this->argument('domain'),
+ 'type' => \App\Domain::TYPE_PUBLIC,
+ ]
+ );
+ }
+ $domain->type = \App\Domain::TYPE_PUBLIC;
+ $domain->tenant_id = $tenant->id;
+ $domain->status = \App\Domain::STATUS_CONFIRMED | \App\Domain::STATUS_ACTIVE;
+ $domain->save();
+
+ $this->info("Created domain {$domain->id}.");
+
+ $tenant->setSettings([
+ "app.name" => $this->option("title"),
+ "app.url" => $this->argument("domain"),
+ "app.public_url" => $this->argument("domain"),
+ "app.support_url" => $this->argument("domain") . "/support",
+ "app.sender.address" => "noreply@kolabnowreseller.kolab.io",
+ "app.sender.name" => $this->option("title"),
+ "app.replyto.address" => "noreply@" . $this->argument("domain"),
+ "app.replyto.name" => $this->option("title"),
+ ]);
+
+ $this->info("Applied default tenant settings.");
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Apr 4, 6:46 PM (2 d, 3 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18830797
Default Alt Text
D4761.1775328407.diff (2 KB)
Attached To
Mode
D4761: Setup all a tenant needs in a single command
Attached
Detach File
Event Timeline