From 8c18836cca617b5c722dc73001d03e685f1b9010 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Thu, 3 Oct 2019 21:59:24 +0200 Subject: [PATCH] Add CreateTenant command, fix TenantList output --- src/Commands/CreateTenant.php | 47 +++++++++++++++++++++++++++++++++++ src/Commands/TenantList.php | 2 +- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 src/Commands/CreateTenant.php diff --git a/src/Commands/CreateTenant.php b/src/Commands/CreateTenant.php new file mode 100644 index 00000000..1c97da07 --- /dev/null +++ b/src/Commands/CreateTenant.php @@ -0,0 +1,47 @@ +withDomains($this->getDomains()) + ->withData($this->getData()) + ->save(); + + $this->info($tenant->id); + } + + public function getDomains(): array + { + return $this->option('domain'); + } + + public function getData(): array + { + return array_reduce($this->argument('data'), function ($data, $pair) { + [$key, $value] = explode('=', $pair, 2); + $data[$key] = $value; + + return $data; + }, []); + } +} diff --git a/src/Commands/TenantList.php b/src/Commands/TenantList.php index a7dd9b9e..3d57df22 100644 --- a/src/Commands/TenantList.php +++ b/src/Commands/TenantList.php @@ -31,7 +31,7 @@ class TenantList extends Command { $this->info('Listing all tenants.'); tenancy()->all()->each(function ($tenant) { - $this->line("[Tenant] id: {$tenant['id']} @ ", implode('; ', $tenant->domains)); + $this->line("[Tenant] id: {$tenant['id']} @ " . implode('; ', $tenant->domains)); }); } }