diff --git a/src/Tenant.php b/src/Tenant.php new file mode 100644 index 00000000..f129f189 --- /dev/null +++ b/src/Tenant.php @@ -0,0 +1,91 @@ +manager = $tenantManager; + } + + public static function new(): self + { + return app(static::class); + } + + public static function fromStorage(array $data): self + { + return app(static::class)->withData($data)->persisted(); + } + + public function persisted() + { + $this->persisted = true; + + return $this; + } + + public function withDomains($domains): self + { + $domains = (array) $domains; + + $this->domains = $domains; + + return $this; + } + + public function withData($data): self + { + $this->data = $data; + + return $this; + } + + public function save() + { + if ($this->persisted) { + $this->manager->addTenant($this); + } else { + $this->manager->updateTenant($this); + } + } + + public function __get($name) + { + return $this->data[$name]; + } +} \ No newline at end of file