From b0d119753de692e251762cc581ad8befa683a37a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Sun, 8 Sep 2019 14:40:49 +0200 Subject: [PATCH] Remove some todos --- src/Contracts/Feature.php | 1 - src/Contracts/StorageDriver.php | 4 ++-- src/Contracts/TenancyBootstrapper.php | 5 ++--- .../QueueTenancyBootstrapper.php | 2 +- src/Tenant.php | 1 - src/TenantModel.php | 18 ++++++------------ 6 files changed, 11 insertions(+), 20 deletions(-) diff --git a/src/Contracts/Feature.php b/src/Contracts/Feature.php index 70307108..fa42da6a 100644 --- a/src/Contracts/Feature.php +++ b/src/Contracts/Feature.php @@ -10,6 +10,5 @@ use Stancl\Tenancy\TenantManager; // todo should this be FeatureProvider? interface Feature { - // todo is the tenantManager argument necessary? public function bootstrap(TenantManager $tenantManager): void; } diff --git a/src/Contracts/StorageDriver.php b/src/Contracts/StorageDriver.php index 98ad10b3..60b1801c 100644 --- a/src/Contracts/StorageDriver.php +++ b/src/Contracts/StorageDriver.php @@ -9,9 +9,9 @@ use Stancl\Tenancy\Exceptions\TenantCouldNotBeIdentifiedException; interface StorageDriver { - public function createTenant(Tenant $tenant): bool; // todo return type + public function createTenant(Tenant $tenant): bool; - public function updateTenant(Tenant $tenant): bool; // todo return type + public function updateTenant(Tenant $tenant): bool; /** * Find a tenant using an id. diff --git a/src/Contracts/TenancyBootstrapper.php b/src/Contracts/TenancyBootstrapper.php index 2ec6aaa8..8d7b0f4b 100644 --- a/src/Contracts/TenancyBootstrapper.php +++ b/src/Contracts/TenancyBootstrapper.php @@ -8,7 +8,6 @@ use Stancl\Tenancy\Tenant; interface TenancyBootstrapper { - public function start(Tenant $tenant); // todo better name? - - public function end(Tenant $tenant); // todo arg? + public function start(Tenant $tenant); + public function end(); } diff --git a/src/TenancyBootstrappers/QueueTenancyBootstrapper.php b/src/TenancyBootstrappers/QueueTenancyBootstrapper.php index a4258445..2465d364 100644 --- a/src/TenancyBootstrappers/QueueTenancyBootstrapper.php +++ b/src/TenancyBootstrappers/QueueTenancyBootstrapper.php @@ -21,7 +21,7 @@ class QueueTenancyBootstrapper implements TenancyBootstrapper $this->app['queue']->createPayloadUsing([$this, 'createPayload']); $this->app['events']->listen(\Illuminate\Queue\Events\JobProcessing::class, function ($event) { if (\array_key_exists('tenant_id', $event->job->payload())) { - tenancy()->initById($event->job->payload()['tenant_id']); // todo + tenancy()->initById($event->job->payload()['tenant_id']); } }); } diff --git a/src/Tenant.php b/src/Tenant.php index e3606f25..95408e0e 100644 --- a/src/Tenant.php +++ b/src/Tenant.php @@ -7,7 +7,6 @@ namespace Stancl\Tenancy; use ArrayAccess; // todo tenant storage -// todo create tenant - create db? /** * @internal Class is subject to breaking changes in minor and patch versions. diff --git a/src/TenantModel.php b/src/TenantModel.php index 902f12e3..4ddc2c6d 100644 --- a/src/TenantModel.php +++ b/src/TenantModel.php @@ -6,25 +6,16 @@ namespace Stancl\Tenancy; use Illuminate\Database\Eloquent\Model; -// todo move this to a database driver domain? - /** * @internal Class is subject to breaking changes in minor and patch versions. */ class TenantModel extends Model { protected $guarded = []; - protected $primaryKey = 'uuid'; + protected $primaryKey = 'id'; public $incrementing = false; public $timestamps = false; - /** - * Decoded data from the data column. - * - * @var object - */ - private $dataObject; - public static function dataColumn() { return config('tenancy.storage.db.data_column', 'data'); @@ -87,10 +78,13 @@ class TenantModel extends Model return $this->attributes[$key] ?? $this->getFromData($key) ?? null; } - /** @todo In v2, this should return an associative array. */ public function getMany(array $keys): array { - return \array_map([$this, 'get'], $keys); + return array_reduce($keys, function ($result, $key) { + $result[$key] = $this->get[$key]; + + return $result; + }, []); } public function put(string $key, $value)