mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 15:54:03 +00:00
Fix feature bootstrapping
This commit is contained in:
parent
689a679f52
commit
9bb56c1b30
5 changed files with 19 additions and 6 deletions
|
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Stancl\Tenancy\Features;
|
||||||
|
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Stancl\Tenancy\Contracts\Feature;
|
use Stancl\Tenancy\Contracts\Feature;
|
||||||
use Stancl\Tenancy\TenantManager;
|
use Stancl\Tenancy\TenantManager;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ class DatabaseStorageDriver implements StorageDriver
|
||||||
|
|
||||||
public function updateTenant(Tenant $tenant): void
|
public function updateTenant(Tenant $tenant): void
|
||||||
{
|
{
|
||||||
Tenant::find($tenant->id)->putMany($tenant->data);
|
Tenants::find($tenant->id)->putMany($tenant->data);
|
||||||
// todo1 update domains
|
// todo1 update domains
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -269,6 +269,9 @@ class Tenant implements ArrayAccess
|
||||||
|
|
||||||
public function __set($key, $value)
|
public function __set($key, $value)
|
||||||
{
|
{
|
||||||
|
if ($key === 'id' && isset($this->data['id'])) {
|
||||||
|
throw new TenantStorageException("Tenant ids can't be changed.");
|
||||||
|
}
|
||||||
$this->data[$key] = $value;
|
$this->data[$key] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -229,10 +229,9 @@ class TenantManager
|
||||||
|
|
||||||
protected function bootstrapFeatures(): self
|
protected function bootstrapFeatures(): self
|
||||||
{
|
{
|
||||||
// todo1 this doesn't work
|
foreach ($this->app['config']['tenancy.features'] as $feature) {
|
||||||
// foreach ($this->app['config']['tenancy.features'] as $feature) {
|
$this->app[$feature]->bootstrap($this);
|
||||||
// $this->app[$feature]->bootstrap($this);
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -205,6 +205,14 @@ class TenantManagerTest extends TestCase
|
||||||
/** @test */
|
/** @test */
|
||||||
public function id_cannot_be_changed()
|
public function id_cannot_be_changed()
|
||||||
{
|
{
|
||||||
// todo1
|
$tenant = Tenant::create(['test2.localhost']);
|
||||||
|
|
||||||
|
$this->expectException(\Stancl\Tenancy\Exceptions\TenantStorageException::class);
|
||||||
|
$tenant->id = 'bar';
|
||||||
|
|
||||||
|
$tenant2 = Tenant::create(['test3.localhost']);
|
||||||
|
|
||||||
|
$this->expectException(\Stancl\Tenancy\Exceptions\TenantStorageException::class);
|
||||||
|
$tenant2->put('id', 'foo');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue