diff --git a/assets/migrations/2019_09_15_000000_create_domains_table.php b/assets/migrations/2019_09_15_000000_create_domains_table.php index 815acd76..07593a25 100644 --- a/assets/migrations/2019_09_15_000000_create_domains_table.php +++ b/assets/migrations/2019_09_15_000000_create_domains_table.php @@ -16,7 +16,7 @@ class CreateDomainsTable extends Migration public function up() { Schema::create('domains', function (Blueprint $table) { - $table->string('tenant_id', 36)->primary(); // 36 characters is the default uuid length + $table->string('tenant_id', 36); // 36 characters is the default uuid length // todo foreign key? $table->string('domain', 255)->index(); // don't change this }); } diff --git a/tests/TenantClassTest.php b/tests/TenantClassTest.php index 1ff4ebd0..73ecb1f6 100644 --- a/tests/TenantClassTest.php +++ b/tests/TenantClassTest.php @@ -7,6 +7,7 @@ namespace Stancl\Tenancy\Tests; use Mockery; use Stancl\Tenancy\Contracts\StorageDriver; use Stancl\Tenancy\Tenant; +use Tenancy; class TenantClassTest extends TestCase { @@ -36,4 +37,13 @@ class TenantClassTest extends TestCase Mockery::close(); } + + /** @test */ + public function tenant_can_have_multiple_domains() + { + $tenant = Tenant::create(['foo.localhost', 'bar.localhost']); + $this->assertSame(['foo.localhost', 'bar.localhost'], $tenant->domains); + $this->assertSame($tenant->id, Tenancy::findByDomain('foo.localhost')->id); + $this->assertSame($tenant->id, Tenancy::findByDomain('bar.localhost')->id); + } }