feat: tenant management console commands

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-07-19 22:38:43 -04:00
parent 2c640125e8
commit 934fb24217
16 changed files with 793 additions and 5 deletions
+8 -3
View File
@@ -3,6 +3,7 @@
namespace KTXC\Stores;
use KTXC\Db\DataStore;
use KTXC\Db\ObjectId;
use KTXC\Models\Tenant\TenantObject;
class TenantStore
@@ -52,7 +53,9 @@ class TenantStore
private function create(TenantObject $entry): ?TenantObject
{
$result = $this->dataStore->selectCollection(self::COLLECTION_NAME)->insertOne($entry->jsonSerialize());
$document = $entry->jsonSerialize();
unset($document['id']);
$result = $this->dataStore->selectCollection(self::COLLECTION_NAME)->insertOne($document);
$entry->setId((string)$result->getInsertedId());
return $entry;
}
@@ -61,7 +64,9 @@ class TenantStore
{
$id = $entry->getId();
if (!$id) { return null; }
$this->dataStore->selectCollection(self::COLLECTION_NAME)->updateOne(['_id' => $id], ['$set' => $entry->jsonSerialize()]);
$document = $entry->jsonSerialize();
unset($document['id']);
$this->dataStore->selectCollection(self::COLLECTION_NAME)->updateOne(['_id' => new ObjectId($id)], ['$set' => $document]);
return $entry;
}
@@ -69,7 +74,7 @@ class TenantStore
{
$id = $entry->getId();
if (!$id) { return; }
$this->dataStore->selectCollection(self::COLLECTION_NAME)->deleteOne([ '_id' => $id]);
$this->dataStore->selectCollection(self::COLLECTION_NAME)->deleteOne(['_id' => new ObjectId($id)]);
}
// =========================================================================